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

Similar documents
Midterm #2 Exam April 26, 2006 CS162 Operating Systems

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

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

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Midterm Exam #2 April 29, 2003 CS162 Operating Systems

Midterm Exam #2 December 4, 2013 CS162 Operating Systems

Problem Max Points Score Total 100

Final Exam Solutions May 11, 2012 CS162 Operating Systems

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

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

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

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Third Midterm Exam April 24, 2017 CS162 Operating Systems

Midterm Exam March 3, 1999 CS162 Operating Systems

Final Exam Solutions May 17, 2013 CS162 Operating Systems

Midterm Exam March 13, 2013 CS162 Operating Systems

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

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

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

Final Exam April 14, 2007 COSC 3407: Operating Systems

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

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

Final Exam Preparation Questions

Midterm Exam October 15, 2012 CS162 Operating Systems

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

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

Virtual Memory. Reading. Sections 5.4, 5.5, 5.6, 5.8, 5.10 (2) Lecture notes from MKP and S. Yalamanchili

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

I/O CANNOT BE IGNORED

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

Chapter-6. SUBJECT:- Operating System TOPICS:- I/O Management. Created by : - Sanjay Patel

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

I/O Device Controllers. I/O Systems. I/O Ports & Memory-Mapped I/O. Direct Memory Access (DMA) Operating Systems 10/20/2010. CSC 256/456 Fall

Second Midterm Exam March 21, 2017 CS162 Operating Systems

Midterm Exam #2 April 16, 2008 CS162 Operating Systems

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

CS5460: Operating Systems Lecture 20: File System Reliability

1. [Lock, Monitor and Deadlock: 5 Lectures (=26%)] 16 Marks [ ]

Midterm Exam #1 September 28, 2016 CS162 Operating Systems

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

Chapter 11 I/O Management and Disk Scheduling

CS-537: Final Exam (Fall 2013) The Worst Case

Database Systems. November 2, 2011 Lecture #7. topobo (mit)

I/O Management and Disk Scheduling. Chapter 11

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 420, York College. November 21, 2006

Midterm Exam March 7, 2001 CS162 Operating Systems

CSE325 Principles of Operating Systems. Mass-Storage Systems. David P. Duggan. April 19, 2011

Chapter 11. I/O Management and Disk Scheduling

CSE 120 Principles of Operating Systems

Storage. Hwansoo Han

(a) Which of these two conditions (high or low) is considered more serious? Justify your answer.

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

I/O Systems and Storage Devices

Virtual File System -Uniform interface for the OS to see different file systems.

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Database Management Systems need to:

Third Midterm Exam November 29, 2017 CS162 Operating Systems

Guerrilla 7: Virtual Memory, ECC, IO

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

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Chapter 7

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Lecture 25: Interconnection Networks, Disks. Topics: flow control, router microarchitecture, RAID

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Operating Systems Comprehensive Exam. Spring Student ID # 2/17/2011

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Disks. Protection & Security

Disks and I/O Hakan Uraz - File Organization 1

CS330: Operating System and Lab. (Spring 2006) I/O Systems

CSE 380 Computer Operating Systems

Chapter 11: File System Implementation. Objectives

Review question: Protection and Security *

19: Networking. Networking Hardware. Mark Handley

ECS 152A Computer Networks Instructor: Liu. Name: Student ID #: Final Exam: March 17, 2005

CSE 153 Design of Operating Systems

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

Main Points of the Computer Organization and System Software Module

Computer Science 461 Midterm Exam March 14, :00-10:50am

CS162 Operating Systems and Systems Programming Lecture 14 File Systems (Part 2)"

CS 537 Fall 2017 Review Session

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

Chapter 6. Storage and Other I/O Topics

File Systems. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

I/O CANNOT BE IGNORED

CSE 410 Final Exam 6/09/09. Suppose we have a memory and a direct-mapped cache with the following characteristics.

RAID (Redundant Array of Inexpensive Disks)

Operating Systems. Week 9 Recitation: Exam 2 Preview Review of Exam 2, Spring Paul Krzyzanowski. Rutgers University.

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

Question Points Score Total 100

This exam paper contains 8 questions (12 pages) Total 100 points. Please put your official name and NOT your assumed name. First Name: Last Name:

CS 550 Operating Systems Spring File System

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

Stanford University Computer Science Department CS 240 Sample Quiz 2 Questions Winter February 25, 2005

CS140 Operating Systems and Systems Programming Final Exam

Computing Science 300 Sample Final Examination

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

20-EECE-4029 Operating Systems Spring, 2013 John Franco

Computer Science 146. Computer Architecture

EE st Term Exam Date: October 9, 2002

I/O 1. Devices and I/O. key concepts device registers, device drivers, program-controlled I/O, DMA, polling, disk drives, disk head scheduling

Transcription:

University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2006 Anthony D. Joseph Midterm #2 Exam April 26, 2006 CS162 Operating Systems Your Name: SID AND 162 Login: TA Name: Discussion Section Time: General Information: This is a closed book and notes examination. You have 90 minutes to answer as many questions as possible. The number in parentheses at the beginning of each question indicates the number of points given to the question; there are 100 points in all. 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!! Problem Possible Score 1 19 2 36 3 23 4 22 Total 100 Page 1/12

1. (19 points total) Short answer questions: a. (11 points) Translation Look-Aside Buffers: i) (6 points) On a TLB miss in Nachos, what data structures should you check to find a previously referenced page? List the data structures in the order that they should be checked. First, you should check the Inverted Page Table, then the swap file, and finally the application COFF file. Each correct answer was worth two points. We subtracted one point for each incorrect answer or wrong order. ii) (3 points) Give a two to three sentence description of precise exceptions. When a precise exception occurs, the Program Counter cleanly divides the fully executed and non-executed instructions there are no partially executed instructions. iii) (2 points) Briefly (1-2 sentences) say why precise exceptions are nice to have. With precise exceptions, there are no side effects or instructions for the exception handler to undo or rollback, making the OS simpler. Page 2/12

b. (4 points) Networking: i) (2 points) The current version of IP uses 32-bit addresses. List one reason that we cannot use all 2 32 addresses. Two reasons: the hierarchical name allocation yields internal fragmentation of network address space, and some of the address are reserved for private networks or other purposes (e.g., x.y.z.0, 127.0.0.1, or localhost). ii) (2 points) List one reason why it would still be possible to connect more than 2 32 computers to the Internet. Two reasons: Network Address Translation allows multiple computers to be connected using a single IP address, and IP addresses can be time-shared using the Dynamic Host Configuration Protocol. c. (4 points) Caching: i) (2 points) What are the two types of locality exploited by caching? Spatial locality and temporal locality. ii) (2 points) Which kind of locality makes large cache lines a good idea, and why? Spatial locality makes large cache lines a good idea because it relies on memory references being to regions near each other. Page 3/12

2. (36 points) File Systems and Disks. a. (8 points) Consider a file system with 2048 byte blocks and 32-bit disk and file block pointers. Each file has 12 direct pointers, a singly-indirect pointer, a doubly-indirect pointer, and a triply-indirect pointer. Express your answers in symbolic form for partial credit. i) (4 points) How large of a disk can this file system support? 2 32 blocks x 2 11 bytes/block = 2 43 = 8 Terabytes. ii) (4 points) What is the maximum file size? There are 512 pointers per block, so: 2048 x (12 + 512 + 512 2 + 512 3 ) = 2 38 + 2 29 + 2 20 + 24k = 256G + 513 M + 24 K. We gave subtracted 1 point each if you did not include the 2K block size, the powers of 512 for indirect pointers, or the overall multiplication b. (12 points) Disk requests come into the disk driver for cylinders: 10, 22, 20, 2, 40, 6, and 38, in that order. The disk head is currently positioned over cylinder 20. A seek takes 6 milliseconds per cylinder moved. What is the sequence of reads and total seek time using each of the following algorithms? i) (4 points) First-come, first-served: 10, 22, 20, 2, 40, 6, 38 10 + 12 + 2 + 18 + 38 + 34 +32 = 146 cylinders = 876 milliseconds. We subtracted 1 point for missing the first reference (to 20), and 1 point for not writing out the sequence of accesses. Page 4/12

ii) (4 points) Shortest Seek Time First: 20, 22, 10, 6, 2, 38, 40 0 + 2 + 12 + 4 + 4 + 36 + 2 = 60 cylinders = 360 milliseconds. iii) (4 points) SCAN (initially moving upwards): 20, 22, 38, 40, 10, 6, 2 0 + 2 + 16 + 2 + 30 + 4 + 4 = 58 cylinders = 348 milliseconds. c. (2 points) Briefly (2-3 sentences) state the difference between a hard link and a soft link. Hard links point to the same inode, while soft links simply list a directory entry. Hard links use reference counting. Soft links do not and may have problems with dangling references if the referenced file is moved or deleted. Soft links can span file systems, while hard links are limited to the same file system. d. (7 points) Read-ahead. i) (3 points) Give a brief (2-3 sentences) description of read-ahead. Prefetching subsequent blocks on the same cylinder when a request is received. We subtracted 1-2 points if your answer didn t clearly state that subsequent blocks were read. ii) (2 points) Briefly (2-3 sentences) state why read-ahead is useful. An application with spatial locality will read the prefetched data (1 pt), avoiding rotational delay and reducing the number of I/O operations (1 pt). We subtracted 1 point if you didn t explicitly state that there are fewer I/O operations. Page 5/12

iii) (2 points) Briefly (2-3 sentences) state what happens if you read ahead too much. Other normal reads can be delayed by prefetching (1 pt), and prefetched data may not be used (1 pt). Also, prefetching replaces blocks in the buffer cache that may be being used, and some files are not sequential, so they won t benefit from prefetching. e. (7 points) RAID i) (3 points) Give a brief (2-3 sentences) description of RAID 5. Redundant Array of Inexpensive Disks level 5 stripes(1 point) blocks of data across at least three drives (1 point) along with an interleaved XOR-based parity block for each stripe set (1 point). ii) (2 points) How many disk failures can RAID 5 tolerate without losing data? One. iii) (2 points) How would you reconstruct a failed disk? Read blocks from the other drives (1 point) and use an XOR (1 point) of their blocks to reconstruct the data. Page 6/12

No Credit Problem X (000000000000 points) The importance of synchronization or You're first after me (This Only Happens in New York City). Race Condition Page 7/12

3. (23 points total) Reliable Peer-to-Peer (P2P) File Sharing. Two computers running a P2P application using TCP/IP for connections are connected via a router (see below). To write data packets to the network, the P2P application issues a system call, and the OS copies the data first to a kernel buffer and then uses DMA to copy the data to the network controller board. Immediately after receiving the data, the controller generates one or more packets and sends them. The packets travel one hop to router RTR, which will in turn forward the packets to their final destination. Assume that no packets will be lost, and assume that the processing time at the router is negligible, and a router must wait for the entire packet to arrive before forwarding it. The receiving network controller uses DMA to copy the data it receives to memory, and when the last bit arrives and is transferred, it interrupts the CPU. The OS copies the data to the P2P application s buffer in user space. After the copy completes, the OS sends back a one-byte acknowledgement to the sending OS. For simplicity, you may treat acknowledgements as if they are zero bytes long. Assume that a sender uses a send window-based acknowledgement protocol. 1 RTR 2 System Parameters: Time to process an interrupt, T int = 1.5 millisecond CPU cycle time, T CPU = 10 nanoseconds Packet size, N pkt = 1,000 bytes (ignore headers) Time to copy or DMA one byte, T copy = 1 microsecond Latency of a link, T link = 3 milliseconds Bandwidth of links, B = 8,000,000 bit/sec Send window N win = 1 packet Retransmission timeout, T retran = 400 milliseconds a. (7 points) Compute T pkt, the time to reliably send a single packet from a P2P application on computer 2 to a P2P application on computer 1 over a link with no losses. T pkt = (4 x N pkt x T copy ) + 2 x T int + 4 x T link + 2 x (8 x N pkt ) / B Each packet is copied 4 times (user-level buffer to kernel buffer, kernel to network card, network card to kernel, and kernel to user-level), which takes 4 ms (4 x N pkt x T copy ). There are 2 interrupts (2 x T int ) for receiving the packet/acknowledgement. Finally, the two-way transmission time is 14 milliseconds (6 ms between RTR and the sender, 1 ms each to receive the packet at RTR and other host, and 6 ms between RTR and the other host) for a total of 21 milliseconds per 1,000 bytes. We subtracted 1 pt each for math errors and each mistake or extra term. Page 8/12

b. (3 points) What is the maximum or peak rate at which one process can reliably send data to another process? T pkt = 21 milliseconds per 1,000 bytes. The maximum rate is N/T pkt = 47,619 byte/sec or 476,190 bit/sec. c. (4 points) In terms of T pkt, how long does it take to reliably send an.mp3 file from computer 2 to computer 1 if the file is 4,000,000 bytes in size (assuming the links have no losses)? 4 million bytes equals 4,000 packets. So, T = (4,000 x T pkt ). At 21 milliseconds per packet it will take 84 seconds. Page 9/12

d. (5 points) If we use a send window of 40 outstanding packets instead, what is the maximum rate at which one process can reliably send data to another process (assuming the links have no losses)? If we can have outstanding acks, then the sending rate is gated by the copying overhead at the sender from user to kernel and then kernel to network card (the receiver s overhead is symmetric) = (2 x N pkt x T copy ) or 2 milliseconds per 1,000 bytes sent. This yields a peak data rate of 500,000 bytes/sec or 4,000,000 bit/sec. Now we need to compare the bandwidth delay product using this rate to the send window, since it could be a potential bottleneck. Using T pkt as the baseline, the bandwidth delay product is 21 milliseconds x 8,000,000 bit/sec or 168,000 bits. The sending window is 40 packets x 8 bits x 1,000 characters or 320,000 bits. So, the limiting factor is the copying overhead, and not the sending window. The correct answer is 4,000,000 bit/sec. e. (4 points) If we use a send window of 40 outstanding packets instead, how long does it take to reliably send an.mp3 file from computer 2 to computer 1 if the file is 4,000,000 bytes in size (assuming the links have no losses)? 4 million bytes equals 4,000 packets, and at 2 milliseconds per packet it will take 8 seconds. We gave partial credit for answers that were consistent with part d, and subtract 1 pt each for minor errors or using T pkt from part a. We did not give credit for answers that were the same as part c. Page 10/12

4. (22 points total) Read-only Page Sharing. To more efficiently use the physical memory allocated to processes, modern operating systems share read-only pages of different running instances of the same application (e.g., multiple Emacs processes). Your task is to implement this functionality for Nachos sharing of read-only COFF pages in Nachos memory. Since we don t have actual inodes in Nachos, it s hard to have a real unique file handle, so it is sufficient if your answer provides a file name. a. (6 points) List the data structures that you would need to add to the kernel: We generally looked for data structures that mapped executable name to physical memory page number (ppn). Example: open_execs: exec_name->coff_info object. Each Coff_Info has file handle/process name, table mapping COFF pages to ppn. If the data structures were only partially sufficient, we subtracted 3 points. b. (4 points) Name all the place where would you have to update these data structures: When you page in/out COFF pages (3 pts) and when you load/unload an application (1 pt). c. (12 points) Design the function load_coff_page() that takes an executable name and virtual page number, and returns a physical page number if that COFF page is already in memory, or -1 if it must be loaded from disk. int load_coff_page( String exec_name, int vpn ) { coff_info = open_execs.get( exec_name ); if (coff_info == NULL) return -1; else return coff_info[vpn]; } We subtracted 6 pts if the answer missed a main point, 2 pts if the answer was inefficient, and 8 pts if the answer had major flaws. Page 11/12

This page intentionally left blank Page 12/12