Virtual Memory & Paging

Answer & solution
Official answer: 0.6
Step through it (17 steps)
Simulating four LRU frames gives faults at reference positions 1, 2, 4, 6, 8, 9, 10, 12, 13, for the values 7, 2, 3, 5, 4, 6, 7, 1, 5. The other six references hit. In particular, the second consecutive 7 hits, and the last 6 and 1 both remain resident. Hence the fault rate is 9/15=0.6.
Maintain recency oldest→newest after each access: [7]; [7,2]; [2,7]; [2,7,3]; [7,3,2]; [7,3,2,5]; [7,2,5,3]; [2,5,3,4]; [5,3,4,6]; [3,4,6,7]; [3,4,6,7]; [4,6,7,1]; [6,7,1,5]; [7,1,5,6]; [7,5,6,1]. On a full-frame miss remove the oldest before appending; on a hit move the referenced page to newest.

![Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.](../../../assets/questions/CS-1993-Q58-1.webp)
![Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.](../../../assets/questions/CS-1993-Q58-2.webp)
![Question 21(a), GATE 1993: Four initially empty page frames receive [1, 2, 3, 4, 1, 3, 5, 2, 1, 5, 4, 3, 2, 3]. Identify each page fault under LRU.](../../../assets/questions/CS-1993-Q58-3.webp)