Page Replacement (FIFO, LRU, Optimal), Unix Inodes & Disk Arm Scheduling
FIFO Belady’s anomaly vs stack algorithms (LRU/Optimal), Unix inode maximum file size formula, and FCFS / SSTF / SCAN / C-SCAN / C-LOOK disk head movement numericals.
1. Page Replacement Algorithms & Stack Property
| Algorithm | Evicts Page... | Suffers Belady’s Anomaly? | Notes |
|---|---|---|---|
| FIFO | Oldest arrival in RAM | YES! (Classic string 1,2,3,4,1,2,5,1,2,3,4,5: 9 faults on 3 frames vs 10 faults on 4 frames!) | Simple queue |
| Optimal (Belady MIN) | Used farthest in the future | No (Stack algorithm) | Theoretical minimum page faults; unimplementable online |
| LRU (Least Recently Used) | Unused longest in the past | No (Stack algorithm: ) | Approximated in hardware via Reference Bit / Clock Second-Chance |
2. Disk Arm Scheduling Algorithms
Suppose cylinders are numbered , head starts at moving toward , and queue = :
- FCFS: Services strictly in arrival order (high wild swings, fair, zero starvation).
- SSTF (Shortest Seek Time First): Always moves to closest pending cylinder from current head (); can cause starvation of far cylinders!
- SCAN (Elevator): Moves all the way to physical boundary (or ) even if no request sits at , then reverses!
- LOOK / C-LOOK: Reverses or jumps right at the last requested cylinder without touching empty boundary / .
SCAN vs LOOK Boundary Trap: In GATE NAT questions, SCAN MUST touch cylinder (or ) before reversing direction, adding extra cylinder distance , whereas LOOK reverses immediately at the extremal request!
🎯 Practice PYQs on This Topic (2)
Which of the following page replacement algorithms can suffer from Belady’s Anomaly (more page faults when allocated more physical page frames)?
A disk head is currently at cylinder and pending requests are at cylinders . Under SSTF (Shortest Seek Time First), which cylinder is serviced first and second?