UNIVERSITY OF WISCONSIN-MADISON
Computer Sciences Department | ||
CS 537
Spring 2001 | A. Arpaci-Dusseau | |
Quiz #7: April 10th -- Virtual Memory |
Name: Solutions | Student ID #: Solutions |
Correct answers are in bold.
A. A policy for determining when to bring a page into memory. B. A policy for determining which page to replace. C. Loading a page into memory only on a page-fault. D. Starting a process with all of its pages resident in physical memory. E. Discarding the least-recently-used (LRU) page in the system.
A. OPT always performs better than or equal to LRU. B. OPT always performs strictly better than LRU. C. LRU always performs better than or equal to FIFO. D. LRU always performs strictly better than FIFO. E. OPT with n+1 pages of physical memory always performs better than or equal to OPT with n pages. F. OPT with n+1 pages of physical memory always performs strictly better than OPT with n pages. G. FIFO with n+1 pages of physical memory always performs better than or equal to FIFO with n pages. H. FIFO with n+1 pages of physical memory always performs strictly better than FIFO with n pages. I. LRU with n+1 pages of physical memory always performs better than or equal to LRU with n pages. J. LRU with n+1 pages of physical memory always performs strictly better than LRU with n pages.
A. When the maximum amount of physical memory is much less than the maximum logical address space. B. When the maximum amount of physical memory is much greater than the maximum logical address space. C. When you want to support page sharing across different address spaces. D. When you are not concerned about page sharing across address spaces.
A. To determine the best page to replace. B. To know when memory is over-committed.Determining the best page to replace can be performed with a page-replacement algorithm such as OPT, LRU, or the clock-algorithm. However, even an optimal page replacement policy can't prevent thrashing when there are simply too many pages being actively referenced by the processes. Therefore, the OS needs to know the number of active pages (i.e., the working set), to determine when memory is over-committed (and there is thrashing), so that an entire process can be swapped out to disk. This reduces the over-committed of memory, which reduces paging and improves CPU-utilization and performance for all.
A. Detecting a protection violation. B. TLB miss. C. Page fault with replacement of dirty page. D. Page fault with replacement of clean page.The ordering B, D, C is straight-forward. A TLB miss simply requires that the OS walk the page tables to find the correct page translation; this is on the order of microseconds. A page fault means the desired page isn't currently present in physical memory; reading it from disk will take many milliseconds. Replacing a dirty page is more expensive than replacing a clean page because the dirty page also has to be written back out to disk.
Detecting a protection violation will be about the same as a TLB miss. The invalid request will always be sent to the TLB initially. If the vpn entry is in the TLB, but has the wrong permissions, this error will cause a trap and be handled by the OS; if the OS is emulating use bits (as in your project), it will walk the page tables to find the "real" protection bits. It may also be the case that the vpn is not in the TLB (this is most likely if the process doesn't have permission at all to access this page), in which case the OS must again walk the page tables to check the protection bits.
Therefore, I would order the costs: A=B, D, C.