1. Assume a system with demand-paged memory. The page table is held in registers. It takes 8ms to service a page fault if an empty frame is available or if the replaced page has not been modified, and 20 ms if the replaced page has been modified. The memory access time is 50 ns. What is the maximum acceptable page-fault rate for an effective memory access time less than 70 ns? Assume that in 60% of all cases the page to be replaced has been modofied. (10 points)
2. A page-replacement algorithm should minimize the number of page faults. One way to obtain this result is to is by distributing heavily used pages evenly over all of memory rather than have them compete for a small number of page frames. We can associate with each page frame a counter indicating how many pages are associated with that particular frame. To replace a page we search for the frame with the smallest counter.
a) Define a page replacement algorithm based on this idea. You must address the problems of (i) what is the initial value stored in counters, (ii) when are counters increased, (iii) when are counters decreased, (iv) how is selected the page to be replaced. Use pseudocode for your algorithm. (30 points)
b) Assuming there are four frames, indicate the page faults and the memory contents, for the following reference string: 1, 2, 3, 4, 5, 3, 4, 1, 6, 7, 8, 7, 8, 9, 7, 8, 9, 5, 4, 5, 4, 2, 7. (10 points)
c) What is the number of page faults if the optimal page-replacement strategy is used, with the same reference string and the same number of frames as in part b? (10 points)
3. Problem 19, page 143, in the textbook. (10 points)
4. Problem 21, page 143, in the textbook. (10 points)
5. Demand paging is designed to be transparent to the user. When programming you do not care much about the details of the memory structure. You want now to do some exploration to see whether it helps to know how paging works or not, and whether it is useful or not, for you as a programmer, to be aware of these details. What you have to do is to experiment with two different programs: test1.c and test2.c are very similar, with the slight difference that they initialize the array called myarray in a different order.
a) Compile the two programs. Since we are interested in performance, you will have to measure the running time. The csh's time command is exactly what you need. This command gives you more information than just the running time: for the format of the output read the man page for csh. Run the two programs and record the running time and the number of page faults in each case. Why is one of the programs significantly slower than the other (think of locality)? (10 points)
b) Limit the amount of physical memory a process can use to half of the maximum of what your process needs. Use the csh's limit command. Run the two programs again. For the program that seems to never finish, find the CPU utilization (use top). After some ten minutes you can stop that program (use Ctrl-C) and record the number of page faults that occurred during this time. Explain your findings. (10 points)
Maximum mark: 100 points (100%)