Virtual Page Number Page Frame Time Loaded Time Referenced R Bit M Bit
2 0 60 161 0 1
1 1 130 160 1 0
0 2 26 162 1 0
3 3 20 163 1 1
A page fault to virtual page 4 has occured at time 164. Which page frame will have its contents replaced for each of the following memory management policies? Explain why in each case.
a. FIFO (first-in-first-out)
Frame 3 since it was loaded the longest ago at time 20.
b. LRU (least recently used)
Frame 1 since it was referenced the longest ago at time 160.
c. Clock
Clear R in Frame 3 (oldest loaded), clear R in Frame 2 (next oldest loaded), victim Frame is 0 since R=0.
d. Optimal (Use the following reference string.)
Replace the page in Frame 3 since the virtual page number 3 (in Frame 3) is used furthest in the future.
e. Given the aforementioned state of memory just before the page fault, consider the following virtual page reference string: 4,0,0,0,2,4,2,1,0,3,2. How many page faults would occur if the working set policy with LRU were used with a window size of 4 instead of a fixed allocation? Show clearly where each fault would occur.
There are 6 faults, indicated by *:
(Window) - {working set}
-----------------------
(1 2 0 3) - {2 1 0 3}
(2 0 3 4) - {2 0 3 4}*
(0 3 4 0) - {0 3 4}
(3 4 0 0) - {0 3 4}
(4 0 0 0) - {0 4}
(0 0 0 2) - {0 2}*
(0 0 2 4) - {0 2 4}*
(0 2 4 2) - {0 2 4}
(2 4 2 1) - {2 4 1}*
(4 2 1 0) - {2 4 1 0}*
(2 1 0 3) - {2 1 0 3}*
(1 0 3 2) - {2 1 0 3}