C-LOOK Disk Scheduling: Jump to the Lowest
Serve requests in one direction only, turn at the last request, then jump straight to the lowest pending request and sweep the same way again.
How C-LOOK Works
- Sort the pending requests by cylinder
- Serve every request at or above the head, lowest first
- At the highest request, stop; do not go on to the edge
- Jump straight to the lowest pending request, serving nothing
- Serve the rest upward, lowest first
C-LOOK, short for circular LOOK, serves requests in one direction only, like C-SCAN, but it never travels further than it has to. Going up, it stops at the highest pending request instead of the last cylinder. Coming back, it jumps to the lowest pending request instead of cylinder 0.
Only the pending requests matter. If they are kept in a sorted list, C-LOOK walks that list from the head's position to the end, then wraps to the start of the list: the list itself is the circle.
- Turns at the last request, not the last cylinder
- Jumps to the lowest request, not cylinder 0
- Needs only the sorted queue, not the disk size
Worked Example: 318 Cylinders from Head 57
This is the queue the other disk scheduling lessons use. The head is at 57 and moving toward higher cylinders.
The five requests above 57 cost 126 cylinders. 183 is the highest, so the arm turns there and jumps to 14, the lowest request, for 169 cylinders. One more move to 37 finishes the queue. Service order: 65, 94, 122, 140, 183, 14, 37.
Most textbooks count the jump, as here. A few leave it out and give 149; an exam answer should say which convention it uses.
| Move | Seek | Running total |
|---|---|---|
| 57 → 65 | 8 | 8 |
| 65 → 94 | 29 | 37 |
| 94 → 122 | 28 | 65 |
| 122 → 140 | 18 | 83 |
| 140 → 183 | 43 | 126 |
| 183 → 14 (jump) | 169 | 295 |
| 14 → 37 | 23 | 318 |
- Order: 65, 94, 122, 140, 183, then 14, 37
- 318 with the jump counted, 149 without
- The jump alone is more than half the total
C-LOOK vs C-SCAN
Both serve in the same order; only the turning points differ. On this queue C-SCAN needs 378 and C-LOOK 318. The 60 cylinders come from two places: C-SCAN runs on from 183 to 199 (16), and it jumps to 0 and climbs back to 14 (199 + 14 = 213) where C-LOOK jumps straight from 183 to 14 (169), a further 44.
So the saving equals the gap between the outermost requests and the disk edges. If the queue contains cylinders 0 and 199, the two algorithms make exactly the same moves. That is a quick check on any worked answer.
Waiting stays even, as in C-SCAN, because the arm still passes every cylinder once per cycle in the same direction. The cycle is just shorter, since it spans the requests rather than the whole disk.
| C-SCAN | C-LOOK | |
|---|---|---|
| Turns at | Cylinder 199 | Highest request, 183 |
| Jumps to | Cylinder 0 | Lowest request, 14 |
| Total head movement | 378 | 318 |
| Needs the disk size | Yes | No |
- Same service order, shorter trips
- Saving = distance from the outer requests to the edges
- Identical when the queue reaches both edges
C-LOOK on the head-57 queue
def c_look(requests, head):
above = sorted(c for c in requests if c >= head)
below = sorted(c for c in requests if c < head)
# The jump spans the queue, not the disk: from the highest request
# straight to the lowest one.
order = above + below
total, position = 0, head
for cylinder in order:
total += abs(cylinder - position)
position = cylinder
return order, total
order, total = c_look([94, 183, 37, 122, 14, 140, 65], 57)
print(" ".join(map(str, order)), "|", total, "cylinders")#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
// Returns total head movement in cylinders; `order` receives the service order.
int cLook(const vector<int>& requests, int head, vector<int>& order) {
int total = 0, position = head;
// The jump spans the queue: highest request straight to lowest.
vector<int> above, below;
for (int c : requests) (c >= head ? above : below).push_back(c);
sort(above.begin(), above.end());
sort(below.begin(), below.end());
for (int c : above) order.push_back(c);
for (int c : below) order.push_back(c);
total = 0;
position = head;
for (int cylinder : order) {
total += abs(cylinder - position);
position = cylinder;
}
return total;
}
int main() {
vector<int> requests = {94, 183, 37, 122, 14, 140, 65}, order;
int total = cLook(requests, 57, order);
for (int c : order) cout << c << " ";
cout << "| " << total << " cylinders" << endl;
return 0;
}import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
// Returns total head movement in cylinders; `order` receives the service order.
static int cLook(int[] requests, int head, List<Integer> order) {
int total = 0, position = head;
// The jump spans the queue: highest request straight to lowest.
List<Integer> above = new ArrayList<>(), below = new ArrayList<>();
for (int c : requests) (c >= head ? above : below).add(c);
Collections.sort(above);
Collections.sort(below);
order.addAll(above);
order.addAll(below);
total = 0;
position = head;
for (int cylinder : order) {
total += Math.abs(cylinder - position);
position = cylinder;
}
return total;
}
public static void main(String[] args) {
int[] requests = {94, 183, 37, 122, 14, 140, 65};
List<Integer> order = new ArrayList<>();
int total = cLook(requests, 57, order);
StringBuilder line = new StringBuilder();
for (int c : order) line.append(c).append(" ");
System.out.println(line + "| " + total + " cylinders");
}
}Step through it
Running on requests 94 183 37 122 14 140 65, head 57 moving up
New Arrivals and Arm Stickiness
Real queues change while the arm moves. A request that arrives ahead of the head joins the current sweep; one that lands behind it waits for the next. With the head at 140, a new request for 150 is served before 183, while a new request for 100 waits until after 37.
One trap catches a careless implementation. If the rule is "serve anything at or above the head" and a program keeps sending requests for the head's own cylinder, the arm never moves on: 183, 14 and 37 wait forever. This is called arm stickiness, and SSTF, SCAN and C-SCAN have it too. Real schedulers avoid it by fixing each sweep's batch before it starts, or by putting new arrivals at the current cylinder into the next sweep.
Among the four sweeping methods, LOOK has the lowest total here (295) and C-LOOK comes second (318). C-LOOK is the one to choose when requests near the edges must not wait longer than ones in the middle. On SSDs there is no arm and none of these orders matters; Linux runs NVMe drives with the none scheduler.
- Ahead of the head: served this sweep; behind it: next sweep
- Same-cylinder streams can pin the arm unless sweeps are batched
- LOOK 295 < C-LOOK 318 < SCAN 327 < C-SCAN 378 on this queue