GATE / CS ARCHIVE

GATE CSE 2014 SET 1 / QUESTION 33

GATE CSE 2014 Set 1 Q33

Operating Systems · Virtual Memory & Paging · Full GATE CSE 2014 Set 1 paper

GATE 2014 Set 1, Q33 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