GateMCQSCIENTIFIC PREP LAB
PlanSign Up
INTERMEDIATEFrequently Tested 4 min read 23 views

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

AlgorithmEvicts Page...Suffers Belady’s Anomaly?Notes
FIFOOldest arrival in RAMYES! (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 futureNo (Stack algorithm)Theoretical minimum page faults; unimplementable online
LRU (Least Recently Used)Unused longest in the pastNo (Stack algorithm: Sm(t)⊆Sm+1(t)S_m(t) \subseteq S_{m+1}(t))Approximated in hardware via Reference Bit / Clock Second-Chance

2. Disk Arm Scheduling Algorithms

Suppose cylinders are numbered 0…1990 \dots 199, head starts at 5353 moving toward 00, and queue = {98,183,37,122,14,124,65,67}\{98, 183, 37, 122, 14, 124, 65, 67\}:

  • 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 (53→65→67→37→14→98→122→124→18353 \to 65 \to 67 \to 37 \to 14 \to 98 \to 122 \to 124 \to 183); can cause starvation of far cylinders!
  • SCAN (Elevator): Moves all the way to physical boundary 00 (or 199199) even if no request sits at 00, then reverses!
  • LOOK / C-LOOK: Reverses or jumps right at the last requested cylinder without touching empty boundary 00 / 199199.
Common Exam Mistake

SCAN vs LOOK Boundary Trap: In GATE NAT questions, SCAN MUST touch cylinder 00 (or M−1M-1) before reversing direction, adding extra cylinder distance 2×dedge2 \times d_{\text{edge}}, whereas LOOK reverses immediately at the extremal request!

3. Interactive 2D Disk Arm Seek Trajectory Plot (SSTF, SCAN, C-SCAN, C-LOOK, FCFS)

Operating Systems2D Cylinder Plot

Disk Arm Seek Trajectory Drawing (SSTF / SCAN / C-SCAN / C-LOOK)

Total Head Movement: 236 cylinders
037536798124183199536567371498122124183
Queue = [98, 183, 37, 122, 14, 124, 65, 67] starting at head 53 (Initial direction: toward 199).
Key Formulas Summary
Unix Inode Maximum File Size
Max Size=(d+p+p2+p3)×B,p=BBlock Ptr Size\text{Max Size} = \left( d + p + p^2 + p^3 \right) \times B, \quad p = \frac{B}{\text{Block Ptr Size}}
Note: d = direct pointers, 1 single-indirect (p), 1 double-indirect (p^2), 1 triple-indirect (p^3), B = block size
Disk Access Time
Taccess=Tseek+12⋅RPS+BytesTransfer RateT_{\text{access}} = T_{\text{seek}} + \frac{1}{2 \cdot \text{RPS}} + \frac{\text{Bytes}}{\text{Transfer Rate}}
Note: Average rotational latency = half of one full disk rotation (30 / RPM seconds)
#Operating Systems#Page Replacement#Belady Anomaly#Unix Inodes#Disk Scheduling

Practice Questions on This Chapter (3)

Q1GATE CS OSMCQEASY
+1M • -0.33

Which of the following page replacement algorithms can suffer from Belady’s Anomaly (more page faults when allocated more physical page frames)?

⚡ Click an option above to verify instantly
Q2GATE CS OSMCQMEDIUM
+2M • -0.67

A disk head is currently at cylinder 5050 and pending requests are at cylinders {82,170,43,140,24,16}\{82, 170, 43, 140, 24, 16\}. Under SSTF (Shortest Seek Time First), which cylinder is serviced first and second?

⚡ Click an option above to verify instantly
Q3GATE CS 2020NATMEDIUM
+2M • 0 Neg

A Unix inode has 1212 direct block pointers, 11 single-indirect, 11 double-indirect, and 11 triple-indirect pointer. Disk block size is 4 KB4\text{ KB} and each block address is 4 bytes4\text{ bytes}. Approximately what is the maximum file size contributed by the double-indirect block alone (in GB)?

Previous TopicVirtual Memory, Multi-Level Paging & TLB Effective Access TimeNext Topic Page Replacement Logics (Animated): Belady’s Anomaly in FIFO vs LRU & Optimal Stack Property