What is the LOOK Disk Scheduling Algorithm?
Learn how the LOOK disk scheduling algorithm works, how it beats SCAN in seek time, and how it differs from C-LOOK, with interview questions.
Expected Interview Answer
LOOK is a disk scheduling algorithm that moves the head in one direction servicing requests, but reverses as soon as there are no more requests in that direction, rather than always traveling all the way to the physical edge of the disk like SCAN does.
Like SCAN, LOOK sweeps toward the highest requested cylinder, servicing every request it encounters along the way, and then reverses direction to sweep toward the lowest requested cylinder. The key difference is that LOOK "looks ahead" at the remaining request queue and turns around at the last pending request in that direction instead of continuing on to cylinder 0 or the maximum cylinder number regardless of whether anything is waiting there. This avoids wasted seek time traveling to and from empty regions of the disk that have no pending requests, making LOOK strictly more seek-efficient than SCAN in the common case where requests do not span the entire disk. The tradeoff versus SCAN is identical algorithmic behavior when requests happen to be spread across the full range, but LOOK never does worse and typically does better, which is why most real implementations favor LOOK or its circular variant, C-LOOK, over plain SCAN.
- Avoids wasted seeks to the physical disk edge with no pending requests
- Never performs worse than SCAN, and often performs measurably better
- Still preserves the fairness benefit of sweeping in a consistent direction
- Forms the basis for C-LOOK, the circular fairness-optimized variant
AI Mentor Explanation
LOOK is like a fielder jogging out to collect balls hit progressively deeper, but stopping and turning back as soon as the last ball in that direction has been picked up, instead of jogging all the way to the boundary rope even when no ball landed there. The fielder then heads back the other way, again stopping at the last ball rather than running to the far boundary unnecessarily. This saves running distance compared to always sprinting edge to edge.
Step-by-Step Explanation
Step 1
Sort pending requests
The scheduler looks at the current queue and identifies the highest and lowest requested cylinders.
Step 2
Sweep toward the far requests
The head moves in its current direction, servicing each request until it passes the last one in that direction.
Step 3
Reverse at the last request
Instead of continuing to the physical disk edge, the head reverses immediately after the last pending request in that direction.
Step 4
Sweep back
The head services requests moving the opposite way, again turning around at the last request rather than the opposite physical edge.
What Interviewer Expects
- Understanding that LOOK reverses at the last request, not the disk edge
- A correct comparison to SCAN highlighting the avoided wasted seeks
- Awareness that LOOK is never worse than SCAN in total seek distance
- Knowledge that C-LOOK is the circular, more fairness-oriented sibling of LOOK
Common Mistakes
- Confusing LOOK with SCAN and assuming it always travels to the physical edge
- Thinking LOOK and C-LOOK are the same algorithm
- Forgetting that LOOK still requires knowing the current request queue ahead of the sweep
- Assuming LOOK guarantees fairness identical to C-LOOK, when plain LOOK can still favor middle cylinders
Best Answer (HR Friendly)
“LOOK moves the disk head back and forth servicing requests, but instead of always traveling all the way to the physical start or end of the disk, it turns around as soon as it passes the last pending request in that direction. That small change avoids wasted travel into empty regions of the disk, so it is generally more efficient than plain SCAN.”
Code Example
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a, const void *b) {
return (*(int *)a - *(int *)b);
}
void look(int requests[], int n, int head, int going_up) {
qsort(requests, n, sizeof(int), cmp);
int total_seek = 0;
int current = head;
int i = 0;
while (i < n && requests[i] < head) i++; /* split point around head */
if (going_up) {
for (int j = i; j < n; j++) { /* service upward requests */
total_seek += abs(requests[j] - current);
current = requests[j];
}
for (int j = i - 1; j >= 0; j--) { /* reverse, service downward */
total_seek += abs(requests[j] - current);
current = requests[j];
}
} else {
for (int j = i - 1; j >= 0; j--) {
total_seek += abs(requests[j] - current);
current = requests[j];
}
for (int j = i; j < n; j++) {
total_seek += abs(requests[j] - current);
current = requests[j];
}
}
printf("Total seek movement (LOOK): %d\n", total_seek);
}Follow-up Questions
- How does LOOK avoid the wasted seeks that plain SCAN incurs?
- What is the difference between LOOK and C-LOOK?
- Can LOOK ever perform worse than SCAN in total seek distance?
- How would you decide between LOOK and SSTF for a given workload?
MCQ Practice
1. When does the disk head reverse direction under LOOK?
LOOK reverses at the last pending request in the current direction instead of always traveling to the disk edge.
2. How does LOOK compare to SCAN in total seek distance?
By avoiding travel into request-free regions of the disk, LOOK matches or beats SCAN’s total seek distance.
3. What is the relationship between LOOK and C-LOOK?
C-LOOK applies LOOK’s edge-avoidance logic together with a circular, one-direction-only servicing pattern like C-SCAN.
Flash Cards
What is LOOK? — A disk scheduling algorithm that sweeps toward requests and reverses at the last pending request, not the disk edge.
How does LOOK differ from SCAN? — SCAN always travels to the physical disk edge; LOOK reverses at the last real request.
Is LOOK ever worse than SCAN? — No — LOOK is never worse and is usually more seek-efficient.
What is C-LOOK? — The circular version of LOOK, combining edge-avoidance with one-direction servicing like C-SCAN.