Question 20

Computer Awareness Memory Management Medium

Consider a page reference string as: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2. Assume that there are 3-page frames available. Calculate the total number of page faults for the above reference string if LRU policy is used for page replacement.

(A) 10
(B) 8
(C) 9
(D) 11
View Dynamic Solution & Explanation
Correct Solution: Option C

Step-by-step Solution:

Solution (LRU with 3 frames)

Reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2

Number of frames = 3. We simulate LRU (least recently used): when a page is referenced, it becomes the most recently used; on a miss, evict the least recently used page.

Step Page Frames (LRU → MRU) Result
17[7]Fault
20[7, 0]Fault
31[7, 0, 1]Fault
42[0, 1, 2]Fault (evict 7)
50[1, 2, 0]Hit (0 becomes MRU)
63[2, 0, 3]Fault (evict 1)
70[2, 3, 0]Hit (0 becomes MRU)
84[3, 0, 4]Fault (evict 2)
92[0, 4, 2]Fault (evict 3)
103[4, 2, 3]Fault (evict 0)
110[2, 3, 0]Fault (evict 4)
123[2, 0, 3]Hit (3 becomes MRU)
132[0, 3, 2]Hit (2 becomes MRU)

Total page faults = 9.

Answer: 9 page faults.