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!
3. Interactive 2D Disk Arm Seek Trajectory Plot (SSTF, SCAN, C-SCAN, C-LOOK, FCFS)
Disk Arm Seek Trajectory Drawing (SSTF / SCAN / C-SCAN / C-LOOK)
[98, 183, 37, 122, 14, 124, 65, 67] starting at head 53 (Initial direction: toward 199).Practice Questions on This Chapter (3)
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?
A Unix inode has direct block pointers, single-indirect, double-indirect, and triple-indirect pointer. Disk block size is and each block address is . Approximately what is the maximum file size contributed by the double-indirect block alone (in GB)?