



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!




NOTE: Please write your ID on every page of the exam.
Total
A set of threads do a computation in a sequence of phases. We wish to have all threads finish phase i before any thread starts computing phase i+1. They do this with barrier synchronization. At the end of each phase, each process executes barrier(n); where n is the number of threads in the computation. A call to barrier(n) blocks until all of the n threads have called barrier(n). Then, all threads proceed. Write a monitor that implements barrier. Use the semantics of Java monitors: a notify does not cause the thread to relinquish the monitor. You don’t have to include the try/catch syntax for catching an error thrown by wait.
One of the most difficult aspects of designing a caching scheme is determining an appropriate replace- ment algorithm. The optimum replacement scheme depends greatly on the observed access patterns, and the appropriate design parameters are not always intuitive. One of the most famous examples of this fact is known as Belady’s anomaly.
(a) What is Belady’s anomaly?
Consider the following access pattern: 1 2 3 4 1 2 5 1 2 3 4 5
(b) How many hits will FIFO achieve with a cache size of 3? 4?
(c) What about Least Frequently Used (LFU)?
(d) Most Frequently Used (MFU)?
(e) Which of FIFO, LFU, and MFU exhibit Belady’s anomaly?
(f) It is well-known that Belady’s anomaly can be avoided by using a stack replacement algorithm that satisfies the inclusion principle. What is the inclusion principle, and why does it prevent Belady’s anomaly?
Given a machine and operating system that supports a hardware-managed TLB and wired two-level page tables, (a) consicely enumerate the steps that are taken to translate a virtual address issued by the CPU into a physical address issued to physical memory, and (b) whether those steps are implemented in hardware by the MMU or in software by the OS. For (a), be sure to describe the various misses and faults that can occur during translation. Then, (c) describe how the translation process differs for a software-managed TLB. Finally, (d) describe what can happen if the page tables are themselves paged and how the OS handles that situation.