









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 Fall 2006 John Kubiatowicz
December 4th^ , 2006 CS162: Operating Systems and Systems Programming
Your Name:
SID Number: Circle the letters of CS Login
First: a b c d e f g h I j k l m n o p q r s t u v w x y z Second: a b c d e f g h I j k l m n o p q r s t u v w x y z
Discussion Section:
General Information: This is a closed book exam. You are allowed 1 page of hand-written notes (both sides). You have 3 hours to complete as much of the exam as possible. Make sure to read all of the questions first, 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. On programming questions, we will be looking for performance as well as correctness, so think through your answers carefully. If there is something about the questions that you believe is open to interpretation, please ask us about it!
Problem Possible Score
Total
Problem 1f[2pts]: “Marshalling” is the process by which Byzantine Generals are forced into making good decisions.
an RPC) into a network message.
Problem 1g[2pts]: RAID-5 is 5 times more reliable than RAID-1.
systems can handle a single disk failure.
Problem 1h[2pts]: One advantage of a software TLB is that the same hardware platform can support both forward and inverse page tables.
page tables in any way desired.
Problem 1i[2pts]: The Use bit in the PTE is required for implementing the Second Chance List algorithm.
that was missing the Use bit in its PTE.
Problem 1j[2pts]: The difference between a computer Worm and a computer Virus is that a Virus requires human action to spread.
attachments in email or on a floppy boot track and require someone to actually click on the attachment or boot the disk to start. Worms can arrive all by themselves, via security flaws in the OS.
Problem 2: Virtual Memory, Paging, and Disks
Problem 2a[2pts]: Suppose that we have a 64-bit virtual address split as follows:
9 Bits [ Table ID]
13 Bits [ Table ID ]
13 Bits [ Table ID ]
13 Bits [ Page ID ]
16 Bits [ Offset ]
Show the format of a PTE complete with bits required to support the clock algorithm, sharing of dynamic libraries, and copy-on-write optimizations.
Answer:
Problem 2b[3pts]: Explain how to implement the clock algorithm (not the Second Chance List algorithm) if the hardware does not directly support use bits or dirty bits.
We assume that the Valid and Writable bits exist in hardware. Since the Use and Dirty bits don’t exist, we need to emulate them in software. First, we use two spare bits in the PTE to represent our emulated versions of Use and Dirty. Second, we use another two spare bits in the PTE to track whether a page is actually valid or writable. On each pass of the clock hand, we check the (software) Use bit as usual. If Use is clear, we recycle the page. If Use is set, we clear it and set the page to invalid. On the next use of the page, we get a page fault (telling us the page is in use). We use this page fault to set the software Use bit and to set the page to read- only. If the application tries to write the page, we get a page fault and can set the software Dirty bit and set the page to read-write.
Problem 2c[4pts]: For the following problem, assume a hypothetical machine with 4 pages of physical memory and 7 pages of virtual memory. Given the access pattern: A B C D E A A E C F F G A C G D C F Indicate in the following table which pages are mapped to which physical pages for each of the following policies. Assume that a blank box matches the element to the left. We have given the FIFO policy as an example.
Access→ A B C D E A A E C F F G A C G D C F 1 A E C 2 B A D 3 C F
48 Bits [Physical Page Frame]
12 Bits [Other Uses]
DirtyUse WritableValid
Any one of these
Problem 2f[5pts]: Assume that there is a queue in front of the controller. Assume that the operating system behaves as in (2e), and that the distribution of service times has C = 1.5 (i.e. not quite memoryless). Also assume that requests for blocks arrive via an exponential (memoryless) process with an average arrival rate of λ blocks/second. What is the arrival rate λ such that the queue has an average length of 10 blocks? You don’t need to actually compute this number as long as you given an explicit equation for λ. Hint: use Little’s law: Lq = λ Tq and solve for utilization.
This is just a straightforward use of the M/G/1 queue formula from class:
Tq = ( ) u
u Tser C −
Where Tser is the service time from 2g, C=1.5, and u= λ ×Tser.
Solving simply (for a queue-length of 10):
Lq =10 = λ ×Tq (Little’s Law)
= ( ) ( ) u
u C u
u Tser C −
Now, we just solve for u (and remembering that C=1.5):
( ) 40 40 5 8 8 0 1
2 ⇒ − = ⇒ + − = −
= + × u u u u u
u C
So, using quadratic formula:
( ) 2 6 4 2
u= u
( ) ( ) Tser 2. 4524 ms
=.367 requests/ms=367 requests/sec
Problem 3: File Systems Please keep your answers short (one or two sentences per question-mark). We may not give credit for long answers.
Problem 3a[3pts]: Rather than writing updated files to disk immediately when they are closed, many UNIX systems use a delayed write-behind policy in which dirty disk blocks are flushed to disk once every 30 seconds. List two advantages and one disadvantage of such a scheme:
Advantage 1: The disk scheduling algorithm (i.e. SCAN) has more dirty blocks to work with at any one time and can thus do a better job of scheduling the disk arm. Advantage 2: Temporary files may be written and deleted before they ever get to disk.
Disadvantage: File data may be lost if the computer crashes before data is written to disk.
Problem 3b[2pts]: Describe a technique that can be used to mitigate the disadvantage of (3a) without losing the advantages of (3a). Be explicit here.
Use an NVRAM (Non volatile RAM). The idea here is that data which is written is placed in the NVRAM right away, before telling the user that it has been written. Since this process is as fast (or nearly so) as writing to RAM and doesn’t involve moving the disk arm, both of the above advantages remain. Since it is nonvolatile, a disk crash will not lose data.
Problem 3c[4pts]: In the following, compare the performance of a FAT file system to a more primitive system that uses “linked allocation” (where file blocks are linked together via pointers in each block) with respect to number of disk accesses. Be sure to state any assumptions that you are making in terms of what (if anything) is memory resident.
a) Which is faster for random access? Explain. (Assume the file in question is large):
The FAT file system is much faster for random access. You read the FAT (once), trace through the links in memory to find the desired block, then read the block from memory (effectively 2 disk accesses). With the linked-allocation, you need to read through (n-1) blocks to randomly access the n th^ block of the file.
b) Which is faster for sequential access? Explain. (Again assume a large file):
This depends on your assumptions. If you are unable to keep the FAT in memory, the linked allocation is faster, since the next block is contained in the previous block. If, on the other hand you assume that the FAT stays in memory, then these two techniques are of equal performance or the FAT could be faster if requests were queued enough to allow better disk scheduling. Note that you needed to state your assumptions to get full credit here.
Problem 3h[3pts]: The Andrew File System (AFS) solves the above problem (3g) using state information it maintains at the server. What state is kept? How is that state used to solve the problem?
An AFS server keeps track of which clients have read-only copies of particular files. Thus, when one client writes data (and closes the file so that the data is flushed to the server), the server contacts each of the clients that have cached copies of the file and tells them to invalidate the file.
Problem 3i[4pts]: At time XZ, the request queue for a disk contains the following requests in [track:sector] form:
[10:5], [22:9], [20:21], [21:9], [2:10], [40:45], [6:7], [38:9] …. (in this order).
Assume that the disk head is currently positioned over cylinder 20. What is the sequence of reads under the following head scheduling algorithms?
a) Shortest Seek Time First:
Only the track numbers matter here (since you can’t really do inter-track optimization). So:
[20:21], [21:9], [22:9], [10:5], [6:7], [2:10], [38:9], [40:45]
b) SCAN (initially moving upwards):
Moving initially upwards (increasing tracks), we have:
[20:21], [21:9], [22:9], [38:9], [40:45], [10:5], [6:7], [2:10]
Problem 4: Security Problem 4a[3pts]: Assume Alice and Bob have never met. Explain how Alice can use a public key infrastructure (PKI) to prove her identity to Bob. Hint: make sure to prevent replay attacks.
The essential insight here is that Alice needs to sign something with her private key that can be verified with her public key. To prove to Bob what her public key is, she has a certificate authority sign her public key. This is the PKI.
Once Bob is certain of Alice’s public key, proving her identity is easy:she signs a message (like “Hi! I’m Alice”) with her private key asserting that she is Alice. To avoid replay attacks, she asks Bob for a random value which she also includes in that message.
Problem 4b[3pts]: Explain how to utilize a PKI to establish a private session key between two parties for fast symmetric encryption.
Both parties use the PKI to make sure that they have each other’s appropriate public key. Then, they each choose a random number, encrypt it with the public key of the other party, and send it off. Now, both of them have the same two random numbers (which are private). They can combine them anyway they like, then use the result as a private session key.
Problem 4c[4pts]: What are two desirable properties for secure hash functions (ignoring the property where half the bits change for small changes in input). Why are these properties important for signatures?
The type of signature discussed in class involves encrypting the hash of a document with the private key of the signer. The properties above prevent the possibility of a single signature from referring to multiple documents (which would defeat the purpose of a signature).
Problem 5a[4pts]: Under ideal circumstances (and ignoring interrupt and copying overheads and window size), what is the maximum bandwidth that Client A can send data to the server without causing packets to be dropped (Assuming that the headers are of zero length and that routers can handle data at wire speed)? How about Client B? Explain.
This is simply a matter of finding the slowest link (bottleneck) along the path.
So: Client A, maximum bandwidth available is 20Mbps (bottleneck from router 3 → server) Client B, maximum bandwidth available is 16Mbps (bottleneck from router 2 → 3)
Problem 5b[4pts]: Keeping in mind that TCP/IP involves a total header size of 40 bytes (for TCP
Here, the key is to compute the minimum MTU along each path. This gives the packet size that we will be using as a result. Then, the data bandwidth needs to be scaled back by subtracting 40 bytes for every packet.
A → server: min MTU=1000bytes. Thus, bandwidth= 1000
Mbps × =19.2 Mbps
B → server: min MTU=200bytes. Thus, bandwidth= 200
Mbps × =12.8 Mbps
Problem 5c[6pts]: Now, assume that copying and interrupt overheads impact the maximum rate at which data can be sent or received at the endpoints (clients or servers). Routers continue to be fully pipelined and senders avoid fragmentation as in 5b. What is the maximum data bandwidth that Client A can transfer to the server without dropping packets? Explain. What about Client B? Hint: make sure to account for the impact of the 40 byte TCP/IP header.
Since DMA can be overlapped with the CPU, the key is to see what bottlenecks prevent the CPU from acting. At the sender, we have one data copy from user → kernel space and one interrupt (ACK). At the destination, we have one interrupt (packet arrival) and one data copy from kernel → user space. Thus, we have the same constraints on both sides. Notice that only the data portion of the packet is copied to and from user space.
However, network limits Client A → Server bandwidth to 19.2Mbps (see 5b)
Since network permits 12.8Mpbs (see 5b), max Client B → Server bandwidth is 11Mbps.
Problem 5d[5pts]: Now, accounting for copying and interrupt overheads, what is the total time to reliably send a single maximal-sized packet from Client A to a user-level process on the server without fragmentation? Account for all latencies (including the reception of an ACK, which can be assumed to be zero length but which will generate an interrupt). Explain your work. We need to compute the path from A to server with the data as well as the time back for the ACK. Note that the data involves raw latency, in addition to copying, DMA, and transfer time along the ling. The ACK has only latency elements. Note that the Copies between user space and kernel space involve the data payload (packet size – 40 bytes). We will assume that the DMAs involve the complete packet (although this is perhaps open to interpretation). Note that we convert everything to ms. We could easily have converted to seconds instead….
DMA + Int + Copy
Problem 5e[4pts]: Assume the conditions from 5d. Client A sends a continuous stream of packets to the server (and no other clients are talking to the server). How big should the send window be so that the TCP/IP algorithm will achieve maximum bandwidth without dropping packets? Explain. Hint: don’t forget to account for the 40 bytes of header.
data we need outstanding to completely fill up the pipeline without putting too much into the network. Since the send window is for real data (not headers), we use the bandwidth numbers from 5c with the latency from 5d. We need to make sure to cancel terms (watch out for seconds vs ms!). Note: Technically speaking, the user copy doesn’t really impact the
correct window of:
Since a fraction of a byte doesn’t make sense, we round down to 44328.
Note that we also gave you full credit if you simply multiplied answer from 5d with 19.2Mbps (which would be correct if window handled by user—not really true):
We can round down 44788 bytes.