SCAN Disk Scheduling Algorithm
SCAN Disk Scheduling Algorithm
Aim
To simulate the SCAN disk scheduling algorithm and compute the total head movement, displaying Step, From, To, Movement.
Theory
The SCAN algorithm moves the disk head in one direction first, servicing all requests in its path until it reaches the end of the disk, then reverses direction and services remaining requests.
Because the head sweeps back and forth like an elevator, SCAN is also called:
👉 Elevator Algorithm
Advantages
-
Better than FCFS in reducing seek time
-
Avoids starvation seen in SSTF
-
Provides more uniform waiting time
Disadvantage
-
Requests at extreme ends may wait longer
Algorithm
-
Read number of disk requests.
-
Read request queue.
-
Read initial head position.
-
Read disk size.
-
Read direction (LEFT or RIGHT).
-
Sort request queue.
-
If direction = RIGHT:
-
Service all requests greater than head (ascending)
-
Move to disk end
-
Reverse and service remaining smaller requests
-
-
If direction = LEFT:
-
Service smaller requests first (descending)
-
Move to 0
-
Reverse and service larger requests
-
-
Compute total movement.
Program: SCAN Disk Scheduling (C)
Example
Input
Sorted Queue
Sample Run (SCAN RIGHT first)
Service right side:
53 → 65 → 67 → 98 → 122 → 124 → 183 → 199 (disk end)
Then reverse:
199 → 37 → 14
Output Table
Observation
| Algorithm | Total Movement |
|---|---|
| FCFS | 640 |
| SSTF | 236 |
| SCAN | 331 |
👉 SCAN gives better fairness than SSTF but sometimes more movement.
Comments
Post a Comment