Question
Consider a demand paging system with three frames, and the following page reference string: 1 2 3 4 5 4 1 6 4 5 1 3 2. The contents of the frames are as follows initially and after each reference (from left to right):
initially after
- 1* 2* 3* 4* 5* 4 1 6* 4 5 1* 3* 2*
- 1 1 1 1 1 1 1 6 6 6 6 6 2
- - 2 2 4 4 4 4 4 4 4 1 1 1
- - - 3 3 5 5 5 5 5 5 5 3 3
The *-marked references cause page replacements.
Which one or more of the following could be the page replacement policy/policies in use?
Official answer and solution
- Official answer
- D
- From
- Official GATE 2025 answer key
Solution
Check each page replacement against future page references (Optimal) and past usage history (LRU, LFU, MFU).
Let us check the replacements after the first three cold misses (1*, 2*, 3*), when the frames hold {1, 2, 3}:
- At
4*: Page2is replaced, leaving{1, 4, 3}.- Under LRU,
1is the least recently used page, so LRU would evict1(eliminating A). - Under Optimal, future references are
5 4 1 6 4 5 1 3 2:1is used at index 7,3at index 12, and2at index 13 (farthest in the future). Thus Optimal evicts2.
- Under LRU,
- At
5*: Frames hold{1, 4, 3}; page3is evicted, leaving{1, 4, 5}.- Under MFU and LFU, all three pages
{1, 4, 3}have frequency ; with FIFO tie-breaking, LFU would evict1, and MFU at later steps (6*when4and5have frequency while1is evicted with frequency ) also fails. - Under Optimal, future references are
4 1 6 4 5 1 3 2:4is used next, then1, and3is used farthest in the future, so Optimal evicts3.
- Under MFU and LFU, all three pages
- At
6*: Frames hold{1, 4, 5}; future references are4 5 1 3 2. Since1is referenced farthest in the future (after4and5), Optimal evicts1. - At
1*,3*,2*: At1*(frames{6, 4, 5}, future3 2), none of{6, 4, 5}is used again, so Optimal can evict4; similarly at3*it evicts5, and at2*it evicts6.
Thus Optimal page replacement policy (D) is the only matching policy.
Option (D)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 47 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.