Skip to main content

GATE CSE 2016Operating System › Memory Management & Virtual MemoryVerified

GATE CSE 2016 PYQ: Consider a computer system with ten physical page frames. The system is provided with an access sequence ( a…

Consider a computer system with ten physical page frames. The system is provided with an access sequence (a1,a2,....,a20,a1,a2,...a20)(a_{1}, a_{2},....,a_{20}, a_{1}, a_{2},...a_{20}), where each aia_{i} is a distinct virtual page number. The difference in the number of page faults between the last-in-first-out page replacement policy and the optimal page replacement policy is_________.

    Answer

    1

    Approach

    Assume all 20 virtual pages are distinct and initially none are in memory. The first 20 accesses are all compulsory misses for both policies. Then simulate the remaining 20 accesses to count additional faults: LIFO evicts the most recently loaded page, while OPT evicts the page whose next use is farthest in the future (or never used again).

    LIFO has 31 page faults and optimal replacement has 30 page faults, so the required difference is 1.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.