Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Disk Scheduling & I/O
OS

Disk Scheduling & I/O

How the OS moves the disk arm efficiently: FCFS, SSTF, SCAN, and the power of RAID and DMA.

I/O is the slowest subsystem in a computer. Disk scheduling algorithms minimize the time spent moving the disk arm (seek time) to service I/O requests.

Disk Performance Metrics

MetricWhat it measuresTypical value
Seek timeMoving arm to the correct cylinder4-10 ms
Rotational latencyWaiting for the right sector under the head2-5 ms (7200 RPM → 4.17 ms avg)
Transfer timeReading/writing the dataDepends on size and bandwidth
Total access timeSeek + Rotational + Transfer10-20 ms

Disk Scheduling Algorithms

AlgorithmHow it worksProsCons
FCFSService requests in arrival orderFair, simpleWorst seek time
SSTFService closest request firstLow average seek timeStarvation for edge tracks
SCAN (Elevator)Sweep across disk, service requests along the wayNo starvationTracks at edges wait longer
C-SCANSweep one direction only, then jump backUniform waiting timeMore seeks than SCAN
LOOK / C-LOOKReverses direction only at the last request (not disk end)More efficient than SCANSlightly more complex

SCAN vs C-SCAN

SCAN moves back and forth like an elevator. C-SCAN only services requests in one direction (e.g., inward), then immediately jumps to the outer edge and repeats. C-SCAN gives more uniform waiting times — no cylinder is unfairly preferred.

DMA (Direct Memory Access)

Without DMA: CPU reads each byte from the device into a register, then stores it to memory — programmed I/O (PIO). The CPU is busy the entire time.

With DMA: CPU tells the DMA controller: “copy 4KB from disk to address 0x1000.” The CPU resumes work. The DMA controller handles the transfer and interrupts the CPU only when done.

Buffering vs Spooling

BufferingSpooling
PurposeOverlap I/O of one process with its computationOverlap I/O of one process with computation of another process
ExampleReading a file in chunks while processingPrint spooler — multiple processes queue print jobs
StorageMemoryDisk

Q: What is seek time vs rotational latency?

A: Seek time is the time for the disk arm to move to the correct cylinder. Rotational latency is the time waiting for the target sector to spin under the head. Total access time = seek + rotational latency + transfer time.

Q: Why is C-SCAN often preferred over SCAN?

A: C-SCAN provides more uniform waiting times. In SCAN, cylinders near the middle get serviced twice per pass while edge cylinders wait longer. C-SCAN treats all cylinders equally by only servicing in one direction.

Q: Why do we use DMA?

A: Without DMA, the CPU must move every byte from device to memory — wasting billions of cycles. DMA lets the CPU initiate the transfer and do other work while a dedicated controller handles the data movement.

Q: What’s the difference between buffering and spooling?

A: Buffering stores data temporarily to handle speed mismatches within a single process. Spooling (Simultaneous Peripheral Operation Online) overlaps I/O of one job with computation of another — like printing documents while you work.

My Private Notes

Notes are auto-saved locally to this device.