GATE / CS ARCHIVE

GATE CSE 2016 SET 1 / QUESTION 49

GATE CSE 2016 Set 1 Q49

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

GATE 2016 Set 1, Q49 2 marks · NAT
Report issue

Virtual Memory & Paging

Question 49, GATE 2016: There are 10 initially empty physical page frames. The reference sequence is a1,a2,...,a 20,a1,a2,...,a 20, with 20 distinct pages. Find the difference between LIFO and optimal replacement in total page faults.
Tap to enlarge
Answer & solution

Official answer: 1.0 : 1.0

Our answer: 1

Assume initially empty frames. Both policies fault on all 20 first-pass pages. LIFO retains a 1 through a 9 and the most recently inserted page a 20. The second pass hits on a 1..a 9 then faults on a 10..a 20, giving 31 faults total. OPT can retain a 1..a 9, a 20 after the first pass, then uses frames of already-consumed pages to service a 10..a 19 while retaining a 20, giving 30. At least 10 second-pass faults are unavoidable because only 10 of 20 distinct pages can initially be resident, so OPT is optimal. Difference 31−30=1.

Under LIFO, page hits do not change insertion order. Once frames fill with a1 through a 10, every first-pass fault replaces the newest page in the same slot; a1 through a9 remain throughout. In the second pass, these nine hit and the other eleven fault. OPT has ten resident pages at the start of the second pass and can fault on exactly the ten absent pages by discarding pages whose final reference has already occurred. The total faults are therefore 31 versus 30, not counts of distinct pages alone.

Original paper, page 18 · Answer key