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_________.

  1. A.

    5

  2. B.

    7

  3. C.

    9

  4. 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.

  1. Access 1: Frames = [1, -, -] — page fault (total faults = 1)

  2. Access 2: Frames = [1, 2, -] — page fault (total faults = 2)

  3. Access 3: Frames = [1, 2, 3] — page fault (total faults = 3)

  4. Access 2: Frames = [1, 2, 3] — hit (no fault, total faults = 3)

  5. Access 4: Evict least recently used (page 1). Frames = [4, 2, 3] — page fault (total faults = 4)

  6. Access 2: Frames = [4, 2, 3] — hit (no fault, total faults = 4)

  7. Access 5: Evict least recently used (page 3). Frames = [4, 2, 5] — page fault (total faults = 5)

  8. Access 2: Frames = [4, 2, 5] — hit (no fault, total faults = 5)

  9. Access 3: Evict least recently used (page 4). Frames = [3, 2, 5] — page fault (total faults = 6)

  10. 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.

Explore the full course: Mppsc Assistant Professor