Page Replacement (FIFO & LRU)
When every frame is full and a new page must be loaded, the OS must choose a victim. Compare FIFO and LRU on the same reference string and measure the hit and fault ratios.
Real-world analogy: Desk with three trays
| Reference | Frame 1 | Frame 2 | Frame 3 | Hit / Fault |
|---|---|---|---|---|
| Press Next step or Auto play to start. | ||||
Total references
0
Page hits
0
Page faults
0
Hit ratio
0.00%
Fault ratio
0.00%
Final result for the whole string
Page Hits : 3 Page Faults : 9 Hit Ratio : 25.00% Fault Ratio : 75.00%
Step 1 · What is happening?
The CPU asks for the next page in the reference string; the OS checks whether that page is already in a frame.
Step 2 · Why this decision?
FIFO evicts the page that entered memory earliest, regardless of how often it is used.
Step 3 · What changes in memory?
On a hit nothing moves (LRU only updates the recency stamp). On a fault the page is loaded into an empty frame, or the victim frame is overwritten.
Step 4 · Resulting state
The frame row is recorded, hit/fault counters update, and the hit and fault ratios are recalculated.
Reference string 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 with 3 frames using FIFO. Find the number of page faults and the hit ratio.
1. Belady's anomaly (more frames → more faults) can occur with…
2. A page hit means…
3. If there are 12 references and 8 faults, the hit ratio is…