LOOK Disk Scheduling: How It Works and When to Use
LOOK disk scheduling is an algorithm that moves the disk arm towards the nearest request in one direction and reverses direction only when no further requests exist in that direction. Unlike SCAN, it does not go to the disk's end but 'looks' ahead to serve requests efficiently, reducing unnecessary movement.How It Works
Imagine a librarian who moves along a shelf to pick books requested by readers. Instead of walking all the way to the end of the shelf every time, the librarian only goes as far as the last requested book in one direction, then turns back to collect requests in the opposite direction. This is how the LOOK disk scheduling algorithm works.
The disk arm moves in one direction, servicing all pending requests until it reaches the furthest request in that direction. It then reverses direction without going to the physical end of the disk. This reduces unnecessary travel, saving time and improving efficiency compared to algorithms that always go to the disk's edge.
Example
This example simulates the LOOK disk scheduling algorithm serving a list of disk requests starting from a given head position.
def look_disk_scheduling(requests, head): requests = sorted(requests) left = [r for r in requests if r < head] right = [r for r in requests if r >= head] seek_sequence = [] # Move towards the right first for r in right: seek_sequence.append(r) # Then reverse and move left for r in reversed(left): seek_sequence.append(r) total_movement = 0 current_position = head for track in seek_sequence: total_movement += abs(track - current_position) current_position = track return seek_sequence, total_movement # Example usage requests = [40, 10, 22, 70, 50, 5] head = 35 sequence, movement = look_disk_scheduling(requests, head) print("Seek Sequence:", sequence) print("Total Head Movement:", movement)
When to Use
LOOK scheduling is useful when you want to reduce the disk arm's movement compared to simpler algorithms like SCAN or FCFS. It is ideal in systems where disk requests are spread out but not necessarily at the disk's edges, such as database servers or file systems with moderate random access.
By avoiding unnecessary travel to the disk's physical ends, LOOK improves response time and reduces wear on the disk hardware. It balances fairness and efficiency, making it a practical choice for many operating systems.
Key Points
- LOOK moves the disk arm only as far as the last request in each direction.
- It reverses direction without going to the disk's physical end, unlike
SCAN. - Reduces total head movement and improves efficiency.
- Works well when requests are unevenly distributed.
- Balances speed and fairness in servicing disk requests.