A disk has 251 tracks and a queue of access requests: 240, 94, 179, 51, 118, 15, 137,
29, and 75. The
Read/Write head (C) is initially located at track 55 and is moving to the right:
The movement towards the right stops at the end of the disk (250), even though no request is at
250. Then, it reverses its direction and stops at the last request (in track 15). Hence, the total head
movement is:
The diagram below illustrates the SCAN algorithm in a case where the head direction is towards the
left:
The movement towards the left stops at the end of the disk (0), even though there’s no request at 0.
Then, the head reverses its direction and stops at the last request (in track 240). Hence, the total
head movement is:
In operating systems, SCAN, LOOK, and C-SCAN are disk scheduling
algorithms that aim to optimize disk access time by moving the disk arm in
a specific direction and servicing requests sequentially. Here's a
breakdown with examples:
SCAN (Elevator Algorithm)
Concept:
The disk arm moves in one direction (e.g., from the beginning to the end of the
disk), servicing requests along the way, then reverses direction and continues
servicing requests in the opposite direction.
Example:
Disk Tracks: 0 to 199
Initial Head Position: 50
Request Queue: 20, 40, 60, 80, 100, 120, 140, 160, 180, 200
Algorithm:
1. The head moves from 50 towards the end (199), servicing requests in order (60, 80,
100, 120, 140, 160, 180, 200).
2. Reverses direction and moves towards the beginning (0), servicing requests in order
(140, 120, 100, 80, 60, 40, 20).
Seek Time:
SCAN can lead to high seek time, especially if requests are clustered at one end of
the disk.
LOOK
Concept:
Similar to SCAN, but instead of moving to the very end of the disk, the head stops
after servicing the last request in the current direction.
Example:
Disk Tracks: 0 to 199
Initial Head Position: 50
Request Queue: 20, 40, 60, 80, 100, 120, 140, 160, 180, 200
Algorithm:
1. The head moves from 50 towards the end (199), servicing requests in order (60, 80,
100, 120, 140, 160, 180, 200).
2. Reverses direction and moves towards the beginning (0), but stops at the last request
in that direction (20).
Seek Time:
LOOK can reduce seek time compared to SCAN by not traveling to the end of the
disk unnecessarily.
C-SCAN (Circular SCAN)
Concept:
The disk arm moves in one direction (e.g., from the beginning to the end), servicing
requests along the way. Once it reaches the end, it "wraps around" to the
beginning and continues servicing requests in the same direction.
Example:
Disk Tracks: 0 to 199
Initial Head Position: 50
Request Queue: 20, 40, 60, 80, 100, 120, 140, 160, 180, 200
Algorithm:
1. The head moves from 50 towards the end (199), servicing requests in order (60, 80,
100, 120, 140, 160, 180, 200).
2. "Wraps around" to the beginning (0) and continues servicing requests in the same
direction (20, 40).
Seek Time:
C-SCAN can provide more consistent response times than SCAN, as it doesn't
have to travel to the end of the disk and back.