CSE120, Fall 2005, Homework 3 Due: November 10, in class 1. [Silberschatz] [10 pts] What is the cause of thrashing? How does the system detect thrashing? Once it detects thrashing, what can the system do to eliminate this problem? 2. [Silberschatz] [10 pts] Why are segmentation and paging sometimes combined into one scheme? 3. [10 pts] Typically, why must the TLB be flushed on a context switch? What feature must the hardware provide in the TLB to obviate flushing on context switch? Why? 4. [McKusick] [10 pts] When a process exits, all its pages may not be placed immediately on the memory free list. Explain this behavior. 5. [McKusick] [15 pts] What is the relationship between paging and swapping on a demand-paged virtual-memory system? Explain whether it is desirable to provide both mechanisms in the same system. 6. [15 pts] Unix provides a flag for the mmap() system call, MAP_PRIVATE, which maps a file as copy-on-write. Explain how this might work by describing how the OS would manage the page tables and virtual memory of a process which calls (1) mmap() with the MAP_PRIVATE flag, then (2) reads some memory from the mmap()ed page, then (3) reads the same memory again, and then (4) writes to the memory. (Suggestion: type 'man mmap' into a Unix shell to get the manual page for mmap().) 7. [Tanenbaum] [15 pts] A group of operating system designers for the Frugal Computer Company are thinking about ways of reducing the amount of backing store needed in their new operating system. The head guru has just sugested not bothering to save the program text in the swap area at all, but just page it in directly from the binary file whenever it is needed. Are there any problems with this approach? 8. [15 pts] Suppose we devise a new page replacement algorithm, MRU, which is like LRU page replacement except that it always replaces the most recently used page rather than the least recently used page. Does MRU suffer from Belady's anomaly? Why or why not? Describe a sequence of page accesses (be sure to specify the number of frames) for which MRU performs better than LRU.