






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







University of California, Berkeley College of Engineering Computer Science Division – EECS
Spring 2003 Anthony D. Joseph
April 29, 2003 CS162 Operating Systems
Your Name:
SID AND 162 Login:
TA:
Discussion Section:
General Information: This is a closed book and notes examination. You have two hours 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!
Problem Possible Score
Solutions
b. (2 points) What is the smallest addressable piece of data on a disk drive? Disk sector or block
c. (2 points) What is a persistent, named collection of data? File or directory
d. (2 points) What is a piece of hardware that caches virtual page → physical page mappings? Translation lookaside buffer or associative memory
e. (8 points) Consider two processes P and Q that are communicating using mailboxes. From P → Q they use mailbox A, and from Q → P they use mailbox B. Assume both mailboxes are currently empty and the communication link between P and Q is reliable. If P now wants to determine that Q has terminated, what is the sequence of instructions that P should execute? You may only use the following blocking instructions: send, reply, re-send, receive, deleteMailbox, createMailbox, and setAlarm. Note that an alarm will interrupt a blocking instruction. P send(A, msg); setAlarm(timeout); receive(B, msg); if timeout then Q has terminated
We awarded 2 points for each part of the solution. We took off 2 points if you had an infinite loop or placed the setAlarm after the receive statement.
Solutions
Problem 2 (cont’d) c. (9 Points) Suppose a file system can have three disk allocation strategies, contiguous, linked, and indexed. We have just read the information for a file from its parent directory. For contiguous and linked allocation, this gives the address of the first block, and for indexed allocation this gives the address of the index block. Now we want to read the 10th^ data block into the memory. How many disk blocks ( R ) do we have to read for each of the allocation strategies? For partial credit, explicitly list which block(s) you have to read.
Contiguous allocation:
1 block We took off one point if you included reading a file header. For major errors, we deducted two points.
Linked allocation:
10 blocks We took off one point if you included reading a file header.
Indexed allocation:
2 blocks We took off one point if you did not read the index block. We took off two points if you assumed the index block was already in memory.
Solutions
The first set of questions is about adding hard links to the file system. a. (4 points) What changes would you make to the internals (directory, fileheader, free map, etc.) of the filesystem to support hard links? You would have to add a link count to the file header. No partial credit.
b. (5 points) How do the semantics of the Remove system call change, and how do you implement that change to Remove and any other affected system calls? Remove must decrement the link count (2 points) and check the on disk link count (3 points). No other system calls are affected and we deducted up to two points if you included other system calls.
c. (3 points) What new system calls, if any, must be added to the system? Give the C language-style signature of any new calls, e.g., int Open(char *file). List the signature and give a one sentence definition of each argument and return value. Add a int Link(char *src, char *dest) or int Link(int inodeNumber, char *dest) to create a new link to an existing file.
Solutions
b. (4 points) How do the security system (e.g., file permissions) and the virtual memory system? This one’s deliberately tricky. If the OS allows memory mapping of files, the memory mapping interface has to respect file system permissions - potentially every time that the file is read or written. This is a potentially very complex interaction. Answers that discussed caching files and the need to keep permission bits correct were worth one point.
Solutions
No Credit – Problem X: (000000000000 points)
Found on the Internet:
Mathematics in 1950: Question: A logger sells a truckload of lumber for $100. His cost of production is 4/5 of the price. What is his profit?
Mathematics in 1960: Question: A logger sells a truckload of lumber for $100. His cost of production is 4/5 of the price, or $80. What is his profit?
Mathematics in 1970: Question: A logger exchanges a set “L” of lumber for a set “M” of money. The cardinality of set “M” is 100. Each element is worth one dollar. Make 100 dots representing the elements of the set “M.” Set “C,” the cost of production, contains 20 fewer points than set “M.” Represent set “C” as a subset of set “M” and answer the following question: What is the cardinality of the set “P” of profits?
Mathematics in 1980: Question: A logger sells a truckload of lumber for $100. His cost of production is $80 and his profit is $20. Your assignment: Underline the number 20.
Mathematics in 1990: Question: By cutting down beautiful forest trees, the logger makes $20. What do you think of this way of making a living? Topic for class participation after answering the question: How did the forest’s birds and squirrels feel as the logger cut down the trees? There are no wrong answers.
Mathematics in 2002: Question: A logger sells a truckload of lumber for $100. His cost of production is $120. How does Arthur Andersen determine that the logger’s profit margin is $60? Bonus points: Explain how an Enron accountant can double this profit by selling the lumber to an out-of-state friend, repurchasing it, and selling it to the State of California.
Solutions
b. (6 points) Sketch a rough graph (“back of the envelope”) illustrating effective network bandwidth as a function of per-message CPU overhead. Indicate any important relative values.
Effective BW
Per-message CPU Overhead
We subtracted 2 points if you didn’t indicate the maximum link bandwidth. If your curve was close to the correct shape, we subtracted 2 points. If your curve was partially incorrect (e.g., intersected the x-axis), we subtracted 4 points.
Depending on the x-axis timescale, your graph could look like this: Effective BW
Per-message CPU Overhead
Max Link BW
Asymptotic to x-axis
Max Link BW
Asymptotic to x-axis
Solutions
Problem 5 (cont’d) c. (6 points) Assume that the receiver can process incoming data at greater than 100 Mbit/s, what is the optimal window size that the receiver should advertise?
The optimal window size will keep the “pipe” full during the time it takes for the data to arrive at the receiver and the ACK to arrive back at the sender. Thus, the receiver should advertise the Bandwidth Delay Product: (2 x 50 milliseconds x100 Mbit/s) = 10 Mbits or 1.25 Mbytes. We subtracted 3 points for answers that used only the one way latency, and we subtracted 3 points for extra terms. For minor math errors, we subtracted 2 points. Note that saying the window size should be infinite or 100 Mbits is incorrect, as that size would yield a sending rate of 1 Gbit/s (100 Mbits sent in 0. seconds) leading to packets being dropped by the network or being queued by the sender’s network driver and then dropped when the queue overflow).
d. (4 points) If the link is shared by N pairs of senders and receivers, does your answer for part (c) change? If so, how? If not, why?
To fairly share the link, the window size for each pair would be 1/N times the answer from (c). We subtracted 2 points if you said the answer changed but didn’t indicate the amount of change.