Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems

Similar documents
Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Final Exam Solutions May 17, 2013 CS162 Operating Systems

Midterm #2 Exam April 26, 2006 CS162 Operating Systems

Midterm Exam #3 Solutions November 30, 2016 CS162 Operating Systems

Midterm #2 Exam Solutions April 26, 2006 CS162 Operating Systems

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Final Exam Solutions May 11, 2012 CS162 Operating Systems

Midterm II December 4 th, 2006 CS162: Operating Systems and Systems Programming

Midterm Exam #2 December 4, 2013 CS162 Operating Systems

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Second Midterm Exam March 21, 2017 CS162 Operating Systems

Problem Max Points Score Total 100

Midterm Exam October 15, 2012 CS162 Operating Systems

Midterm Exam Solutions and Grading Guidelines March 3, 1999 CS162 Operating Systems

Midterm Exam #2 April 29, 2003 CS162 Operating Systems

Midterm Exam #1 September 28, 2016 CS162 Operating Systems

Midterm Exam March 3, 1999 CS162 Operating Systems

Midterm II December 3 rd, 2007 CS162: Operating Systems and Systems Programming

Midterm Exam March 13, 2013 CS162 Operating Systems

Final Exam Preparation Questions

Midterm Exam #2 Solutions October 25, 2016 CS162 Operating Systems

University of California College of Engineering Computer Science Division- EECS. Midterm Exam March 13, 2003 CS162 Operating Systems

CS 537 Fall 2017 Review Session

Midterm Exam #2 April 16, 2008 CS162 Operating Systems

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

3/3/2014! Anthony D. Joseph!!CS162! UCB Spring 2014!

Computer Science 162, Fall 2014 David Culler University of California, Berkeley Midterm 2 November 14, 2014

IMPORTANT: Circle the last two letters of your class account:

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

Section 11: File Systems and Reliability, Two Phase Commit

2 nd Half. Memory management Disk management Network and Security Virtual machine

First Midterm Exam September 28, 2017 CS162 Operating Systems

(b) External fragmentation can happen in a virtual memory paging system.

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

Operating Systems Design Exam 2 Review: Spring 2011

CS 416: Opera-ng Systems Design March 23, 2012

Final Review. Geoffrey M. Voelker. Final mechanics Memory management Paging Page replacement Disk I/O File systems Advanced topics

Third Midterm Exam November 29, 2017 CS162 Operating Systems

CS Operating system

Student Name: University of California at Berkeley College of Engineering Department of Electrical Engineering and Computer Science

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

Computer Science 162, Fall 2014 David Culler University of California, Berkeley Midterm 2 November 14, 2014

Midterm II SOLUTIONS December 5 th, 2005 CS162: Operating Systems and Systems Programming

Virtual Memory Management

Midterm I February 28 th, 2019 CS162: Operating Systems and Systems Programming

Page 1. Review: Storage Performance" SSD Firmware Challenges" SSD Issues" CS162 Operating Systems and Systems Programming Lecture 14

20-EECE-4029 Operating Systems Fall, 2015 John Franco

1993 Paper 3 Question 6

CSE 120 Principles of Operating Systems

CS370 Operating Systems

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

Question Points Score Total 100

University of California, Berkeley. CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM

CS 153 Design of Operating Systems Winter 2016

Fall COMP3511 Review

Stanford University Computer Science Department CS 140 Midterm Exam Dawson Engler Winter 1999

Operating Systems Comprehensive Exam. Spring Student ID # 3/20/2013

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

Midterm Exam #1 Solutions February 28, 2018 CS162 Operating Systems

Administrative Details. CS 140 Final Review Session. Pre-Midterm. Plan For Today. Disks + I/O. Pre-Midterm, cont.

CS153: Final Review1. Chengyu Song. Slides modified from Harsha Madhyvasta, Nael Abu-Ghazaleh, and Zhiyun Qian

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Section 10: Device Drivers, FAT, Queuing Theory, Memory Mapped Files

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Operating Systems, Fall

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

Midterm Exam March 7, 2001 CS162 Operating Systems

Chapter 8: Virtual Memory. Operating System Concepts

Address spaces and memory management

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

COS 318: Operating Systems. Virtual Memory and Address Translation

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

COMP 3361: Operating Systems 1 Final Exam Winter 2009

Multi-level Page Tables & Paging+ segmentation combined

Name: Instructions. Problem 1 : Short answer. [48 points] CMU / Storage Systems 23 Feb 2011 Spring 2012 Exam 1

Lecture 21: Reliable, High Performance Storage. CSC 469H1F Fall 2006 Angela Demke Brown

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

CS4411 Intro. to Operating Systems Final Fall points 10 pages

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CSE 451: Operating Systems. Section 10 Project 3 wrap-up, final exam review

Main Points. File layout Directory layout

COL331/COL633 Major Exam Operating Systems Sem II, Answer all 14 questions (12 pages) Max. Marks: 41

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

CSE380 - Operating Systems

Final Exam April 14, 2007 COSC 3407: Operating Systems

CS-537: Final Exam (Spring 2011) The Black Box

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

CS140 Operating Systems and Systems Programming

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

CMSC 313 Lecture 13 Project 4 Questions Reminder: Midterm Exam next Thursday 10/16 Virtual Memory

CS3600 SYSTEMS AND NETWORKS

CS370 Operating Systems

The memory of a program. Paging and Virtual Memory. Swapping. Paging. Physical to logical address mapping. Memory management: Review

CS 162 Midterm Exam. October 18, This is a closed book examination. You have 60 minutes to answer as many questions

Department of Electrical Engineering and Computer Sciences Fall 2016 Instructors: Randy Katz, Bernhard Boser

CS 537: Introduction to Operating Systems Fall 2015: Midterm Exam #1

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

Transcription:

University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2016 Anthony D. Joseph Midterm Exam #2 Solutions April 20, 2016 CS162 Operating Systems Your Name: SID AND 162 Login: TA Name: Discussion Section Time: General Information: This is a closed book and one 2-sided handwritten note examination. You have 80 minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicates the number of points for that question. You should read all of the questions before starting the exam, as some of the questions are substantially more time consuming. Write all of your answers directly on this paper. Make your answers as concise as possible. If there is something in a question that you believe is open to interpretation, then please ask us about it! Good Luck!! QUESTION POINTS ASSIGNED POINTS OBTAINED 1 12 2 26 3 24 4 22 5 16 TOTAL 100 Page 1/14

1. (12 points total) True/False and Why? CIRCLE YOUR ANSWER AND WRITE AN EXPLANATION (no credit will be given if no explanation is provided). a. In addition to greatly reducing the overall failure probability, moving from a single hard drive to using RAID 1 (mirroring) can also increase the throughput of small random reads. TRUE FALSE Why? TRUE. The small reads need only be sent to a single disk, so in theory, a RAID-1 system can double small random read throughput. The correct answer was worth 2 points and the justification was worth an additional 2 points. b. The TCP transport protocol provides a reliable, in-order bytestream abstraction. TRUE FALSE Why? TRUE. These are exactly the characteristics of TCP. The correct answer was worth 1 point and the justification was worth an additional 2 points. Page 2/14

c. The Byzantine failure model allows arbitrary behavior by a faulty system component. TRUE FALSE Why? TRUE. That is the definition of the model. The correct answer was worth 2 point and the justification was worth an additional 2 points. d. Remote Procedure Calls provide identical semantics to local calls. TRUE FALSE Why? FALSE. RPCs can suffer from network/server failures, so the users need to deal with this difference. The correct answer was worth 2 points and the justification was worth an additional 2 points. Page 3/14

2. (26 points total) Memory and I/O. a. (12 points) For each statement, CIRCLE the address translation scheme(s) for which the statement is true. i) (4 points) A process cannot directly read or write another process memory. Assume there is no mmap() operation. No translation Base and Bound Segmentation Paging Base and Bound, Segmentation, and Paging. ii) (4 points) External fragmentation may occur. No translation Base and Bound Segmentation Paging Base and Bound and Segmentation. Page 4/14

iii) (4 points) Part of the process stack could be swapped out to disk while the process continues to execute using the rest of the stack. Assume the stack is located in a typical location for the type of address translation in use. No translation Base and Bound Segmentation Paging Paging b. (10 points) Consider a system with the following specifications: 46-bit virtual address space Page size of 8 KBytes Page table entry size of 4 Bytes Every page table is required to fit into a single page How many levels of page tables would be required to map the entire virtual address space? In the space below, document the format of a virtual address under this translation scheme. Briefly explain your rationale. A 1-page page table contains 2,048 or 2 11 PTEs (2 2 *2 11 = 2 13 bytes), pointing to 2 11 pages (addressing a total of 2 11 * 2 13 = 2 24 bytes). Adding a second level yields another 2 11 pages of page tables, addressing 2 11 * 2 11 * 2 13 = 2 35 bytes. Adding a third level yields another 2 11 pages of page tables, addressing 2 11 * 2 11 * 2 11 * 2 13 = 2 46 bytes. So, we need 3 levels. The correct answer is worth 3 pts. Correct reasoning is worth up to 7 pts (2 pts for identifying that there are 2 11 PTEs per page, 2 pts for describing how page tables are nested, and 3 pts based upon the quality of the argument): 11 bit page 11 bit page 11 bit page 13 bit offset Page 5/14

c. (4 points) Briefly explain, in four sentences or less, what is DMA and why DMA enables a system to more efficiently handle I/O devices. With DMA, the CPU does not have to be involved in the transfer of each byte or word. It is only involved in the set up of the transfer. Page 6/14

3. (24 points total) Demand Paging. a. (18 points) Consider a demand paging system with 3 pages of physical memory. When a page fault occurs, we use a page replacement algorithm to make space for the new page by evicting a page from memory. Using the FIFO, Clock Algorithm, and LRU page replacement algorithms, mark which pages will be in physical memory after each page request. The first 3 rows for each algorithm are pre-filled for you. For the clock algorithm, on a page fault the clock hand advances before performing any checks or actions. Time FIFO Clock LRU A B C D A B C D A B C D A X X X B X X X X X X C X X X X X X X X X D X X X X X X X X X B X X X X X X X X X A X X X X X X X X X B X X X X X X X X X A X X X X X X X X X D X X X X X X X X X C X X X X X X X X X Number of page faults 7 6 6 Page 7/14

b. (4 points) When a page fault occurs and a page is evicted, what entries in which data structures must the OS invalidate? When a page fault occurs, the OS must invalidate the TLB entry and page table entry corresponding to the evicted page. c. (2 points) In the N th chance page replacement algorithm, explain the purpose of the parameter N. Consider the effects of a small or large N. N enables the OS to approximate the behavior of an LRU algorithm by tracking approximately how long a page it is since a page was last referenced. A larger value of N will enable a more finer grain approximation of LRU. Page 8/14

4. (22 points total) Disks and File Systems. a. (6 points) Name two performance-improving features that are provided by modern disk controllers. For each of the features you name, briefly explain the benefits and consequences of a disk controller that does not provide that feature. i) Feature #1 Benefits and consequences if it is not provided: We decided to grade this question more leniently by interpreting performance to be techniques/features that improve the performance of disk operations OR reduce the complexity of the OS. Note that we did not accept SMR as an answer because it somewhat reduces the performance of reads (due to the high degree of ECC required) and it significantly reduces the performance of writes (due to the need to write an entire shingled region when writing a single block). Track buffer Reads an entire track when a sector is requested. Pro: makes sequential reads faster. Con: without it OS has to implement read ahead. Note that we did not accept answers that confused the OS buffer cache with a disk track buffer. TRIM for SSD. Pro: improves performance of writes. Con: slow writes due to need to erase before writing ECC for HDDs. Pro: can recover data from failing sector. Con: data loss Disk scheduling. Pro: higher performance due to reduced seek/rotational latencies. Con: more seek/rotational latency overhead DMA support. Pro: higher performance due to reduced CPU overhead. Con: higher CPU overhead. Sector interleaving/spanning or track skewing. Pro: higher performance for sequential access due to reduced rotational latencies. Con: higher rotational latencies. Remapping of defective sectors/slip sparing. Pro: enables Logical Block Addressing so the OS can view the disk as a linear sequence of blocks. Con: without it OS, would have to manually keep track of failed sectors and the locations of alternate sectors. Accelerometer for protection against drops. Pro: helps reduce damage by moving head to spare track upon detection of a fall. Con: Damage to HDD. RAID. Pro: helps protect against disk failure. Con: disk failure causes data loss Disk buffers for writes. Pro: faster writes. Con: slower writes ii) Feature #2 Benefits and consequences if it is not provided: See above. Page 9/14

b. (5 points) If a disk subsystem receives an average of 10 requests per second and each request has an average response time of 500ms, how many requests are in the subsystem on average? Explain your answer. 5. We can apply Little s Law: L = λw, where λ is the average arrival rate (10 requests per second) and W is the average response time (1/2 a second) c. (4 points) The FAT file system eliminates external fragmentation by allocating disk space in block-sized units. Considering that fact, briefly explain why defragmentation is still sometimes necessary. The disk blocks allocated to a file may be scattered across the disk. Page 10/14

d. (3 points) In the UNIX 4.2 BSD FFS, inodes have direct pointers, a singly indirect pointer, a doubly indirect pointer, and a triply indirect pointer. The maximum file size supported by this inode type is approximately the same as the maximum file size supported by an inode with only a triply indirect pointer. Briefly explain one disadvantage of an inode design that only uses a triply indirect pointer instead of a combination of pointers (other than the slightly reduced maximum file size). Every file access would require four additional disk reads. e. (4 points) Briefly, in one to three sentences, explain the purpose of the journal in a journaling file system? The journal is used to store the intentions of the OS when making changes to the file system structures (and the data in a full journaling file system). During boot, the journal is used to redo(or complete) any incomplete operations (operations that were in-progress at the time of an OS crash or power failure). Page 11/14

5. (16 points total) Pintos coding question: Verifying user pointers. Your project group is tasked with implementing a new syscall for Pintos. This syscall takes a linked list as one of its arguments, and your responsibility is to create a function that checks the validity of the linked list, so the syscall handler can safely dereference it. The value of head may be NULL, if the list is empty. This is function signature of your syscall: void foo(struct node *head); We have also defined the structure of the node struct, as well as exit_thread_if_invalid(), a function that will verify the validity of userspecified pointers. struct node { int number; char buffer[16]; struct node *next; // If this is the last node, next = NULL }; /* Checks that P to P+SIZE- 1 is a valid user buffer. Kills the current thread if it is invalid. */ void exit_thread_if_invalid(void *p, size_t size); uint32_t SYS_FOO = 60; // The syscall number for foo() Fill in the syscall_handler() function on the next page so that it safely handles the SYS_FOO syscall. Page 12/14

static void syscall_handler (struct intr_frame *f) { uint32_t* args = ((uint32_t*) f- >esp); exit_thread_if_invalid(args, 4); // Check if this is SYS_FOO if (_args[0] == SYS_FOO ) { exit_thread_if_invalid(&args[1], 4); struct node *head = args[1]; while (head!= NULL) { exit_thread_if_invalid(head, sizeof(struct node)); head = head- >next; Page 13/14

// This will actually handle SYS_FOO, // assuming arguments are valid handle_foo(args, &f- >eax); } else { // Code for ALL other syscalls will go here. } } Page 14/14