∑GateAndNet
Practice MCQs
GATE CS / Operating Systems
Edit
INTERMEDIATE🔥 High-Yield Exam Topic 4 min read 3 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.
🚨 Exam Trap Alert

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!

📐 Quick Revision Formula Sheet
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}}
💡 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}}
💡 Average rotational latency = half of one full disk rotation (30 / RPM seconds)
#Operating Systems#Page Replacement#Belady Anomaly#Unix Inodes#Disk Scheduling

🎯 Practice PYQs on This Topic (2)

Q1.GATE CS OSMCQEASY
+1 Marks • -0.33 Neg

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

Q2.GATE CS OSMCQMEDIUM
+2 Marks • -0.67 Neg

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?

Previous TopicVirtual Memory, Multi-Level Paging & TLB Effective Access TimeNext Topic Functional Dependencies, Candidate Keys & Normalization (1NF–BCNF)