GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Trace optimal farthest future page replacement

2 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Both give an explicit reference string and initially empty frame pool; evict the resident page whose next use is farthest away or absent and count faults. Values differ.

2 marks · NAT
Report issue

Virtual Memory & Paging

Question 33, GATE 2014: Three page frames are initially empty. For page references 1,2,3,4,2,1,5,3,2,4,6, how many page faults occur with optimal replacement?
Tap to enlarge
Answer & solution

Official answer: 7

Step through it (13 steps)

1. Method and setup. On a fault with full memory, evict the resident page whose next reference is farthest in the future, treating never-used-again pages as infinitely far away. This uses future knowledge and is an optimal benchmark, not LRU. Mark hits explicitly so that each reference contributes at most one fault.

2. Work through the result and its assumptions. Load1, 2, 3 (three faults). At4 evict 3, whose next use is later than 1/2 (fourth fault). Hits2, 1 follow. At5 evict 1, never used again (fifth). At3 evict 5, never reused (sixth). Then2 and 4 hit; 6 causes the seventh fault. This is Belady’s farthest-future policy.

Original paper, page 15 · Answer key

2 marks · MCQ
Report issue

Optimal replacement page-fault count

Virtual Memory & Paging

Question 82, GATE 2007: A process has three initially empty page frames and reference string 1,2,1,3,7,4,5,6,3,1. How many page faults occur with optimal replacement?
Options:
(A) 7
(B) 8
(C) 9
(D) 10
Question 82, GATE 2007: A process has three initially empty page frames and reference string 1,2,1,3,7,4,5,6,3,1. How many page faults occur with optimal replacement?
Options:
(A) 7
(B) 8
(C) 9
(D) 10
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (12 steps)

1. Approach. At a miss with full frames, evict the page whose next reference lies farthest in the future, treating never-used-again pages as farthest. Keeping pages 1 and 3 is valuable because both are referenced at the end.

2. Derivation and interpretation. For references 1,2,1,3,7,4,5,6,3,1 with three initially empty frames, first load 1,2,3 (the second reference to 1 hits). When 7 arrives, discard 2 because it is never needed again. Retain 1 and 3 while replacing the third frame successively by 7,4,5,6; each of these pages has no future use. The final 3 and 1 then hit. Faults are on 1,2,3,7,4,5,6, totaling 7, option A. Seven distinct pages also give a matching lower bound.

Original paper, page 20