GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 54

Simulating four-reference lookahead replacement

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

GATE 2025 Set 1, Q54 2 marks · NAT
Report issue

Virtual Memory & Paging

Question 54, GATE 2025: Three page frames start empty. References are 1,3,2,4,2,3,1,2,4,3,1,4. A modified optimal replacement algorithm predicts only a window of four references including the current request, evicting the resident page used farthest in that window, or absent from it. Count page faults.
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (14 steps)

Approach: Simulate each request, and on a full-frame miss inspect only the allowed lookahead window.
Requests 1,3,2 fill the empty frames and cause three faults, leaving {1,2,3}. At request 4 (position 4), the window is [4,2,3,1]. Among resident pages, 1 is used farthest away, so evict 1 and load 4: fault 4, frames {2,3,4}. The next requests 2 and 3 hit.
At position 7, request 1 misses. The window [1,2,4,3] places resident 3 farthest in the future, so evict 3: fault 5, frames {1,2,4}. Requests 2 and 4 then hit.
At position 10, request 3 misses. Only [3,1,4] remains. Resident 2 is absent from that window, so evict 2: fault 6, frames {1,3,4}. The last two requests, 1 and 4, hit.
There are six faults, at positions 1,2,3,4,7,10. No replacement tie affects this trace. The current request is included in the four-reference horizon, so the prediction is of at most three additional future accesses, not four.

Original paper, page 54 · Answer key