Consider a virtual page reference string 1, 2, 3, 2, 4, 2, 5, 2, 3, 4. Suppose…
2018
Consider a virtual page reference string 1, 2, 3, 2, 4, 2, 5, 2, 3, 4. Suppose LRU page replacement algorithm is implemented with 3 page frames in main memory. Then the number of page faults are_________.
- A.
5
- B.
7
- C.
9
- D.
10
Attempted by 156 students.
Show answer & explanation
Correct answer: B
Approach: Simulate the LRU algorithm with 3 page frames and update recency on each access.
Access 1: Frames = [1, -, -] — page fault (total faults = 1)
Access 2: Frames = [1, 2, -] — page fault (total faults = 2)
Access 3: Frames = [1, 2, 3] — page fault (total faults = 3)
Access 2: Frames = [1, 2, 3] — hit (no fault, total faults = 3)
Access 4: Evict least recently used (page 1). Frames = [4, 2, 3] — page fault (total faults = 4)
Access 2: Frames = [4, 2, 3] — hit (no fault, total faults = 4)
Access 5: Evict least recently used (page 3). Frames = [4, 2, 5] — page fault (total faults = 5)
Access 2: Frames = [4, 2, 5] — hit (no fault, total faults = 5)
Access 3: Evict least recently used (page 4). Frames = [3, 2, 5] — page fault (total faults = 6)
Access 4: Evict least recently used (page 5). Frames = [3, 2, 4] — page fault (total faults = 7)
Final answer: Total page faults = 7
Key tip: Track the most recent use time for each page; when a replacement is needed evict the page with the oldest last-use time.
A video solution is available for this question — log in and enroll to watch it.