Third Midterm Exam April 24, 2017 CS162 Operating Systems

Similar documents
Third Midterm Exam April 24, 2017 CS162 Operating Systems

Midterm Exam #1 September 28, 2016 CS162 Operating Systems

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

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

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

Midterm #2 Exam April 26, 2006 CS162 Operating Systems

Final Exam Solutions May 11, 2012 CS162 Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

Final Exam Solutions May 17, 2013 CS162 Operating Systems

Midterm Exam October 15, 2012 CS162 Operating Systems

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

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

Third Midterm Exam November 29, 2017 CS162 Operating Systems

Midterm Exam #2 April 29, 2003 CS162 Operating Systems

Problem Max Points Score Total 100

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

Second Midterm Exam March 21, 2017 CS162 Operating Systems

Midterm Exam March 3, 1999 CS162 Operating Systems

First Midterm Exam September 28, 2017 CS162 Operating Systems

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

Midterm Exam #2 December 4, 2013 CS162 Operating Systems

Midterm Exam March 13, 2013 CS162 Operating Systems

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

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

Midterm Exam #1 February 28, 2018 CS162 Operating Systems

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

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

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

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

Name: 1. CS372H: Spring 2009 Final Exam

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

First Midterm Exam September 28, 2017 CS162 Operating Systems

CPS 310 first midterm exam, 10/6/2014

Midterm Exam #2 April 16, 2008 CS162 Operating Systems

CS Operating system

Midterm Exam March 7, 2001 CS162 Operating Systems

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

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

CS3600 SYSTEMS AND NETWORKS

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Name: uteid: 1. CS439H: Fall 2011 Final Exam

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

CS140 Operating Systems and Systems Programming

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 21: Network Protocols (and 2 Phase Commit)

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

CS 370 Operating Systems

CS510 Operating System Foundations. Jonathan Walpole

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

Final Exam Preparation Questions

Network Protocols. Sarah Diesburg Operating Systems CS 3430

Midterm Exam Solutions March 7, 2001 CS162 Operating Systems

CS/CoE 1541 Final exam (Fall 2017). This is the cumulative final exam given in the Fall of Question 1 (12 points): was on Chapter 4

CS-537: Midterm Exam (Spring 2001)

EECS 3214 Midterm Test Winter 2017 March 2, 2017 Instructor: S. Datta. 3. You have 120 minutes to complete the exam. Use your time judiciously.

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

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

Midterm - Winter SE 350

Section 5: Thread Synchronization

Last time. Distributed systems Lecture 6: Elections, distributed transactions, and replication. DrRobert N. M. Watson

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

EECE.4810/EECE.5730: Operating Systems Spring 2017

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES

COMP 3361: Operating Systems 1 Final Exam Winter 2009

CPS 310 midterm exam #2, 4/10/2017

File Systems: Consistency Issues

York University Lassonde School of Engineering Department of Electrical Engineering and Computer Science

CS122 Lecture 15 Winter Term,

Midterm - Winter SE 350

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

CSC 261/461 Database Systems Lecture 20. Spring 2017 MW 3:25 pm 4:40 pm January 18 May 3 Dewey 1101

CS 537 Fall 2017 Review Session

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

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

L7: Performance. Frans Kaashoek Spring 2013

Linux Operating System

OPERATING SYSTEMS II DPL. ING. CIPRIAN PUNGILĂ, PHD.

CS162 Operating Systems and Systems Programming Lecture 17. Disk Management and File Systems

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability

What are Transactions? Transaction Management: Introduction (Chap. 16) Major Example: the web app. Concurrent Execution. Web app in execution (CS636)

There are 10 total numbered pages, 5 Questions. You have 60 minutes. Budget your time carefully!

CPS 512 midterm exam #1, 10/7/2016

Stanford University Computer Science Department CS 240 Quiz 2 with Answers Spring May 24, total

EECS 482 Introduction to Operating Systems

There are, of course, many other possible solutions and, if done correctly, those received full credit.

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

CMU Storage Systems 20 Feb 2004 Fall 2005 Exam 1. Name: SOLUTIONS

Transaction Management: Introduction (Chap. 16)

OPERATING SYSTEM. Chapter 12: File System Implementation

Chapter 12: File System Implementation

Midterm Exam #1 September 29, 1999 CS162 Operating Systems

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

CSE 333 Lecture 9 - storage

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Computer Systems Engineering: Spring Quiz I

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

Chapter 11: Implementing File Systems

Lecture 13: Transport Layer Flow and Congestion Control

Page 1. Quiz 18.1: Flow-Control" Goals for Today" Quiz 18.1: Flow-Control" CS162 Operating Systems and Systems Programming Lecture 18 Transactions"

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

Transcription:

University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2017 Ion Stoica Third Midterm Exam April 24, 2017 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 24 2 15 3 12 4 16 5 15 6 18 TOTAL 100 Page 1/13

P1 (24 points total) True/False and CIRCLE YOUR ANSWER. For each question: 1 point for true/false correct, 2 point for explanation. An explanation cannot exceed 2 sentences. a) When two processes mmap() the same region of a file, mmap() will always return the same set of virtual addresses to both processes, which represent a shared region of memory. The virtual addresses are not necessarily the same, both sets will point to the same physical region. b) A TCP sender can overflow the receiver s buffer. Flow control will make sure the sender never sends more bytes than the receiver can store. Page 2/13

c) It is not possible to develop an agreement protocol between two hosts (i.e., a protocol in which the two hosts agree to do something simultaneously) over an unreliable network? Assume there exists a protocol, and assume N is the minimum number of message of any such protocol. Since the sender of the last message cannot be sure whether the message has been delivered, we can remove the message from the protocol, which contradicts the fact that N is the smallest number of messages. This is the General s Paradox. d) Two-Phase Commit does not guarantee all ACID properties (Atomicity, Consistency, Isolation, and Durability). Only has Atomicity and Durability. e) The end-to-end principle states that one should make the lower levels between the higher-level ends as reliable and secure as possible. The E2E principle says the opposite. f) FAT provides slower sequential access to a file than Unix File System. Page 3/13

FAT needs to perform a disk access for every block to find the pointer to that block, while Unix File System gets the pointers to many blocks by reading an inode. g) Using quorum consensus a writer can return before the data has been written to all replicas. The writer returns after it hears form W replicas, where W is typically smaller than the total number of replicas, N. h) With consistent hashing (e.g., Chord) if a new node is added to a system consisting of N > 1 nodes, this will lead to keys from every node to be moved around. Let s A be the new node. Only the keys of A s successor will be moved to A. P2 (15 points) Transactions. Consider two variables A and B which are initialized to 1, and 2, respectively: Page 4/13

A 1 B 2 Consider the following two transactions being attempted on A and B: Transaction 1 Transaction 2 A=3 B=4 Commit A=5 B=6 Commit For the following scenarios, list which ACID property was violated or none if the transactions obeyed ACID, explain your answer in 1 sentence: a) (3 points) Transaction 1 successfully committed, then the computer crashed after step 2 (B=6) of transaction 2 (but before writing the commit record to the log). State after Recovery: A 3 B 4 Correct ACID behavior. Txn 1 committed, txn 2 did not. b) (3 points) The transactions were run on two threads (at the same time) and have both committed. Note: concurrent transactions may complete in any order. State which order your answer assumes (if any). State after Recovery: A 3 B 4 Order (2, 1): Correct ACID behavior. Isolation only requires some serialized order (the outcome is as if one transaction ran to completion, then the next ran to completion), overwriting old commits is perfectly acceptable. Order (1, 2): Durability (or maybe isolation) was violated. Durability: The changes from the latest committed transaction were not reflected in the final state (most recent changes were lost). Isolation is possible if you assume that B logged its changes, then A ran to completion, then B committed. Page 5/13

c) (3 points) The transactions were run on two threads (at the same time) and have both committed. Note: concurrent transactions may complete in any order. State which order your answer assumes (if any). Final State: A 3 B 6 Isolation was violated. A and B got interleaved. In this case, there was no total order so they may assume either order. d) (3 points) Transaction 1 successfully committed, then the computer crashed during transaction 2 (before commit). State after Recovery: A 5 B 4 Atomicity was violated. B was only partially performed. e) (3 points) Both transactions committed (in order txn1,txn2), then the computer crashed. State after Recovery: A 3 B 4 Durability was violated. Txn 2 was lost despite committing. Page 6/13

P3 (12 points) Synchronization. Consider the following C program. int thread_count = 0; void *thread_start(void *arg) { thread_count++; if (thread_count == 3) { char *argv[] = {"/bin/echo", 162 is the best!, NULL}; /* Replace current process image with a new process image * that runs program pointed by *argv with arguments argv */ execv(*argv, argv); } printf("thread: %d\n", thread_count); return NULL; } int main(int argc, char *argv[]) { int i, status; for (i = 0; i < 2; i++) { pid_t pid = fork(); if (pid!= 0) { thread_count++; wait(&status); } pthread_t *thread = malloc(sizeof(pthread_t)); /* start new thread. The new thread starts execution by invoking * thread_start() with NULL arg. */ pthread_create(thread, NULL, &thread_start, NULL); pthread_join(*thread, NULL); } return 0; } a) (8 points) Provide one possible output from this C program. Thread: 1 Thread: 2 162 is the best! Thread: 2 162 is the best! Thread: 4 b) (4 points) Is the output deterministic? If yes, give a short explanation why. If no, explain how to make the output deterministic. Page 7/13

Yes. Each process is serialized by its wait, and each thread is serialized by pthread_join. P4 (16 points) Queueing theory Consider a system with a single queue and a single server. The arrival rate of the requests follows a Poisson process, and the service time is exponential distributed. Thus, the system implements an M/M/1 queue. Assume that: The utilization U is 50%. The average service time T ser = ⅙ seconds. λ a) (4 points) What is the average service rate µ and arrival rate ƛ? Service rate μ is 1/Tser, so 6 jobs per second. Utilization, u = λ/μ, so λ = u * μ = 3 jobs per second. a) (4 points) What are the average time spent in the queue T q and the response time? Tq = Tser*u / (1-u) = (1/6)*(1/2)/(1-1/2) = ⅙ seconds. Tsys = Tq + Tser = ⅙ + ⅙ = ⅓ seconds. b) (4 points) What is the average length of the queue L q? By little s law, this is lambda * Tq = 3 * ⅙ = ½ jobs. c) (4 points) Assume that we add an additional server with the same service time (T ser = ⅙ seconds) to help service our queue. What is the average time spent in the queue T q and response time for the new system, assuming the same arrival rate as at point (a), and that requests are balanced equally across the two servers? u is now half because the requests are split over the two servers. Tq = Tser*(u/(1-u)) = (1/6)*(1/4)/(1-1/4) = 1/18 seconds. Tsys = Tq + Tser = 1/18 + 1/6 = 4/18 seconds. Page 8/13

P5: (15 points) Caching and storage: You have been hired at a hot startup located in downtown Berkeley and you are tasked with building a key-value store backed by spinning disks. Each disk has the following performance: Bandwidth: 100MB/s Disk controller latency: 1ms Average rotational latency: 3ms Seek latency: 3ms In front of the backing store you have provisioned an in-memory caching layer. The performance of this layer is bounded by the capacity of the network, which is 100MB/s. Each access to the key-value requests translates into one access into the cache and, if there is a cache miss, to one access to one backing disk. Each access results in reading 1 key-value of 100 KB, which is stored contiguously on the disk (i.e., on adjacent sectors.) Ignore the network and cache latency. a) (5 points) Considering your workload hits the cache 50% of the time, what is the average service time (i.e., the time/latency to retrieve a key-value)? Service time to read a key-value from disk = = controller latency + rotation latency + seek latency + transfer time = 1ms + 3ms + 3ms + 100KB/100MBps = 8ms Service time to read a key-value from cache: 100KB/100MBps = 1ms Average service time = 0.5*1ms + 0.5*(8ms + 1ms) = 0.5 + 4.5 = 5ms. We gave partial credit for not including service time to read a key-value from cache. We also considered solutions that don t account for cache updates as correct (average 4.5ms). b) (5 points) What is the maximum number of requests (reads) per second that this system can handle? Requests per second = 1s/5ms = 200 request/sec We gave partial credit to solutions that didn't include service time to read a key-value from cache. c) (5 points) Now consider that you decide to change your spinning disks with faster SSDs to achieve an average service time (i.e., the time/latency to retrieve a keyvalue) of 1.25ms. Assume that the SSD controller latency is 1ms, the same as the HDD controller latency. What is the bandwidth of the SSD? Page 9/13

Service time to read from SSD = (1ms + 100KB/X) Average service time = 0.5*1ms + 0.5*(1ms + 100KB/X) = 1.25ms => 1ms + 100 KB/X = 1.5ms => X = 200MB/s We gave partial credit to solutions that didn't include service time to read a key-value from cache. P6 (18 points) TCP Flow Control. Assume host S uses TCP to send 1000 bytes of data to host R. We make the following assumptions: The maximum packet size is 300B. Maximum size of R s receiving buffer is 500B. The delay between the machines is much larger than the time it takes to S to send 1KB, i.e, S could send 1KB faster than it takes to hear back an ack from R. R consumes the bytes as soon as it receives them (i.e., R s OS sends data to receiving app as soon as it gets them.) a) (6 points) Assume no packet or acknowledgement is lost. Draw the packet diagram also indicating the bytes in R s sending buffer and the bytes in S s receiving buffer. For the acknowledgements indicate both the sequence of next expected byte, and the advertised window. The first packet with the associated information is drawn for you. Initial advertised window (AdvWindow) is equal with the receiver buffer size which is 500B. Also, while below we also show sender window (SendWin), there was no penalty for not showing it, as the problem didn t ask for it. Page 10/13

b) (6 points) Draw the packet diagram assuming the acknowledgement of the first packet is lost. No other packet or acknowledgement is lost. Page 11/13

c) (6 points) Draw the packet diagram assuming the third packet from the sender is lost. No other packet or acknowledgement is lost. Page 12/13

Page 13/13