What are disk scheduling algorithms?
Why Interviewers Ask This
This tests whether you can apply Operating Systems knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Disk scheduling algorithms determine the order in which disk I/O requests are served. Goal: minimize seek time (time for disk arm to move to correct track) and rotational latency. FCFS (First Come First Served): serve requests in order of arrival. Fair but slow — disk arm may zigzag wildly. Example: head at 53, requests: [98,183,37,122,14,124,65,67] → total seek: 640 cylinders. SSTF (Shortest Seek Time First): serve the request closest to current head position. Reduces seek time but causes starvation of distant requests. Example: head at 53 → 65→67→37→14→98→122→124→183 → total: 236 cylinders. SCAN (Elevator algorithm): disk arm moves in one direction serving all requests, then reverses. Like an elevator. No starvation. Better than SSTF for uniformly distributed requests. Example: head at 53 moving right → 65→67→98→122→124→183→(reverse)→37→14 → total: 208. C-SCAN (Circular SCAN): like SCAN but when reaching the end, immediately jumps to the other end (without serving requests on return trip). More uniform wait time than SCAN. C-LOOK: like C-SCAN but only goes to the last request in that direction, not the disk end. More practical. LOOK: like SCAN but reverses at last request, not disk end. Modern considerations: SSDs have no seek time — disk scheduling algorithms are less relevant. SSDs use different optimization strategies (merge writes, wear leveling). NVMe SSDs have multiple queues — parallel request handling.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Operating Systems answers easy to follow.