Simulation of SSTF, LOOK, and C-SCAN Disk Scheduling
Simulation of SSTF, LOOK, and C-SCAN Disk Scheduling
Aim
To simulate SSTF, LOOK, and C-SCAN disk scheduling algorithms for a disk with 5000 cylinders (0–4999) using randomly generated requests, and compute the total head movement for each algorithm.
Theory
SSTF (Shortest Seek Time First)
-
Selects the request closest to current head position.
-
Minimizes immediate seek time.
-
May cause starvation.
LOOK
-
Head moves in one direction servicing requests.
-
Stops at last request, then reverses.
-
Avoids unnecessary movement to disk ends.
C-SCAN
-
Head moves only in one direction.
-
After reaching last cylinder, jumps to 0.
-
Provides uniform waiting time.
Algorithm
-
Accept initial head position from command line.
-
Generate 10 random cylinder requests (0–4999).
-
Display generated requests.
-
Simulate:
-
SSTF → nearest request each time
-
LOOK → service right then reverse
-
C-SCAN → service right → go to end → jump to 0 → continue
-
-
Calculate total head movement.
-
Print comparison results.
Program (C Implementation)
Compilation
Execution
(1200 = initial head position)
Sample Output (example)
(Values change every run due to randomness.)
Result
The SSTF, LOOK, and C-SCAN disk scheduling algorithms were successfully simulated for a disk of 5000 cylinders using randomly generated requests, and their total head movements were compared.
Comments
Post a Comment