Objective
Feed a reference string through FIFO, LRU and Optimal page replacement and count page faults for each on the same frames.
The idea
Frames are scarce, so when a new page must load, one old one must leave. Each algorithm has its own idea of who should go - count the faults to see who's right.
Try this
- 1Run the same reference string under all three policies.
- 2Watch LRU evict the page not used the longest ago.
- 3Find a string where FIFO and LRU disagree on the best victim.
- 4Add a frame and see Belady's anomaly trip up FIFO.
Watch for
- A page fault is a miss: the page is not in memory.
- LRU uses the past to guess the future - usually wisely.
- Optimal evicts the page used furthest in the future (the dream).
- More frames usually mean fewer faults - but not always.