Question
A computer has twenty physical page frames which contain pages numbered 101 through 120. Now a program accesses the pages numbered 1, 2, ..., 100 in that order, and repeats the access sequence THRICE. Which one of the following page replacement policies experiences the same number of page faults as the optimal page replacement policy for this program?
Official answer and solution
- Official answer
- D
- From
- Official GATE 2014 answer key
Solution
Analyze eviction behavior on cyclical reference sequences longer than available physical page frames.
-
Problem Setting:
- 20 physical frames containing initial pages 101 to 120.
- Access sequence: repeated 3 times.
- Let loop length and frames .
-
Optimal Page Replacement Behavior:
- In the first round, accessing pages 1 through 20 causes 20 page faults, filling all 20 frames with pages .
- When page 21 is accessed, an eviction must occur. The optimal algorithm evicts the page whose next request occurs latest in the future.
- In the sequence, after page 100 finishes round 1, round 2 requests pages in order .
- Thus, page 1 will be needed earliest, then page 2, ..., while page 20 will be needed furthest in the future among pages in memory!
- Optimal therefore evicts page 20 to load page 21. Next, when page 22 arrives, page 21 is evicted, and so on.
- In this way, Optimal always evicts the page that was brought in most recently, keeping pages permanently in memory for subsequent rounds!
-
Comparison with Standard Policies:
- LRU and FIFO: Evict page 1, then page 2, ..., completely flushing the loop and suffering a 100% miss rate on all subsequent passes.
- Most-Recently-Used (MRU): Explicitly evicts the most recently referenced page on every miss. Thus, it keeps the early pages in memory and only cycles the 20th frame, exactly mirroring the optimal replacement policy for this loop.
-
Conclusion:
MRU experiences the same number of page faults as the optimal policy, corresponding to option (D).
D
Assuming LRU performs well on cyclic loops; for loops larger than memory size, LRU exhibits the worst possible performance.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 2
- Question
- 43 of 65, printed as CS Q.33
- 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.