Sub topic 6
SCAN, C-SCAN, LOOK and C-LOOK
Prerequisites and the main idea
This chapter assumes that you know what a disk head, cylinder, and disk request are. It also assumes that you can add absolute distances.
Disk scheduling chooses the order in which pending requests are served. The goal is usually to reduce head movement while keeping response times reasonably fair.
The four algorithms in this chapter move the head in an ordered direction:
- SCAN moves in one direction, serves requests along the path, reaches the disk edge, and reverses.
- C-SCAN moves in one direction only. At an edge, it returns to the opposite edge without serving requests during the return.
- LOOK works like SCAN but reverses at the last request in that direction instead of going to the physical edge.
- C-LOOK works like C-SCAN but jumps from the last request in one direction to the first request at the other end.
Worked example
Suppose cylinders range from 0 through 199. The head starts at 53, requests are:
98, 183, 37, 122, 14, 124, 65, 67
Assume the initial direction is upward.
| Algorithm | Service order, including endpoints | Total movement |
|---|---|---|
| SCAN | 53 → 65 → 67 → 98 → 122 → 124 → 183 → 199 → 37 → 14 | 331 |
| C-SCAN | 53 → 65 → 67 → 98 → 122 → 124 → 183 → 199 → 0 → 14 → 37 | 382 |
| LOOK | 53 → 65 → 67 → 98 → 122 → 124 → 183 → 37 → 14 | 299 |
| C-LOOK | 53 → 65 → 67 → 98 → 122 → 124 → 183 → 14 → 37 | 322 |
For SCAN, the head travels from 53 to 199, then back to 14:
(199 - 53) + (199 - 14) = 146 + 185 = 331
LOOK avoids the unnecessary trip to cylinder 199. It reverses at request 183:
(183 - 53) + (183 - 14) = 130 + 169 = 299
C-SCAN and C-LOOK provide more uniform waiting times because requests are served in one direction. However, their return or jump adds movement.
Choosing between the algorithms
SCAN is useful when requests arrive continuously and fairness matters. C-SCAN gives more uniform waiting because a request does not wait through a reverse sweep. LOOK and C-LOOK reduce movement when the request queue does not reach the disk edges.
def movement(path):
return sum(abs(a - b) for a, b in zip(path, path[1:]))
look_path = [53, 65, 67, 98, 122, 124, 183, 37, 14]
print(movement(look_path)) # 299Exercise
Why does LOOK usually move less than SCAN?
Show answer
LOOK reverses at the last pending request instead of traveling to the physical disk edge.