A disk spins at 6,000 RPM, has an average seek time of 4 ms and 400 sectors of 512 bytes per track. Find the average time to read 10 consecutive sectors, the effective bandwidth, and the time and bandwidth for reading one whole track.
Disk scheduling orders pending I/O requests to cut seek time. Know the disk's geometry, the access-time formula (seek + rotational latency + transfer), FCFS, SSTF, SCAN, C-SCAN, LOOK and C-LOOK head-movement numericals, RAID levels and how SSDs change the picture.
A hard disk drive (HDD) stacks several rigid platters on a spindle; each platter has two recording surfaces. A read–write head flies a few nanometres above each surface, and all the heads are mounted on one disk arm (actuator) that moves them together. Each surface is divided into concentric tracks, and each track into sectors — traditionally 512 bytes, now often 4 KB (Advanced Format). The set of tracks at one arm position, one per surface, is a cylinder.
Platters spin at a constant speed: 5,400 or 7,200 RPM for desktop drives, 10,000–15,000 RPM for enterprise drives. Outer tracks are longer, so modern drives put more sectors on them (zoned bit recording) and transfer data faster there. The OS does not see cylinders and heads any more: the drive presents a one-dimensional array of logical blocks (logical block addressing, LBA), with block 0 the first sector of the first track of the outermost cylinder, numbering proceeding through that track, the rest of the cylinder, and then cylinder by cylinder inward. That is why “cylinder number” in exam questions is a stand-in for “block address”.
Disk bandwidth is the total bytes transferred divided by the total time from the first request to the completion of the last. Seek time and rotational latency are pure positioning costs, so the classic optimisation targets are fewer and shorter seeks (scheduling) and larger contiguous transfers (allocation and buffering).
When a process needs disk I/O it issues a system call naming the operation, the disk address, the memory address and the amount of data. If the drive is busy, the request joins a queue, and with many processes the queue is often long. The OS (or the drive itself) can then choose the order of service. Because seek time dominates and is roughly proportional to seek distance, the classic measure is total head movement in cylinders. Plot any queue of your own in the Disk-scheduling plotter on this page.
FCFS services requests in arrival order. It is intrinsically fair and never starves a request, but the arm may swing wildly from one edge of the disk to the other and back; total head movement is usually the worst of all the algorithms.
SSTF (shortest seek time first) always services the pending request closest to the current head position. It is the disk's version of SJF and greatly reduces head movement compared with FCFS. Like SJF it can cause starvation: if new requests keep arriving near the head, a request at the far edge may wait indefinitely. And it is not optimal — a greedy choice of the nearest request can force a long trip later, so SCAN or LOOK sometimes beat it.
SCAN starts at one end of the disk and moves the arm toward the other end, servicing requests as it reaches each cylinder; at the end the direction reverses and servicing continues. Because it behaves like a building's lift, it is called the elevator algorithm. You must know the current direction of the head; a question usually gives it, or gives the previous request so you can infer it.
SCAN treats the cylinders unevenly: a middle cylinder is passed at regular intervals, but a request that arrives near one end just after the head has turned away waits for an almost complete sweep to the other end and back. On average, requests near the ends wait about twice as long as those in the middle, and when the head reverses, the densest pile of waiting requests is at the far end. C-SCAN (circular SCAN) fixes this by servicing in one direction only: when the head reaches the end it returns immediately to the beginning without servicing anything on the way back, treating the cylinders as a circular list. Waiting times become more uniform.
In practice the arm need not go all the way to the physical end. LOOK is SCAN that reverses at the last pending request in the current direction; C-LOOK is C-SCAN that, after the last request in the servicing direction, jumps straight to the first pending request at the other end (not to cylinder 0). These are the versions real systems implement.
Stallings adds two variants that limit how long a request can be ignored: N-step SCAN splits the queue into sub-queues of length N and processes one sub-queue at a time with SCAN, while FSCAN uses two queues — one is serviced while all new requests go into the other. Both stop a burst of new requests near the head from monopolising the arm.
| Algorithm | Service order | Goes to disk end? | Starvation? | Notes |
|---|---|---|---|---|
| FCFS | Arrival order | No | No | Fair; usually the largest head movement |
| SSTF | Nearest request first | No | Yes | Big improvement over FCFS; greedy, not optimal |
| SCAN | Sweep in one direction, then reverse | Yes | No | Elevator algorithm; middle cylinders favoured |
| C-SCAN | One direction only, then return to start | Yes (both ends) | No | Uniform waiting time |
| LOOK | Like SCAN, but reverse at the last request | No | No | Usually beats SCAN |
| C-LOOK | Like C-SCAN, but jump to the lowest pending request | No | No | Uniform waits with less travel than C-SCAN |
Which to choose? SSTF is common and natural and works well under light load. SCAN and C-SCAN (in their LOOK forms) perform better on heavily loaded disks because they cannot starve anyone. Performance also depends heavily on the file-allocation method: a contiguously allocated file produces requests close together, while linked or indexed files scatter them. The scheduling algorithm should therefore be a replaceable module of the OS.
Modern drives schedule internally as well (SATA Native Command Queuing), and they can also account for rotational position — shortest access time first — which the OS cannot see. Linux's multi-queue block layer offers the mq-deadline, bfq, kyber and none I/O schedulers; the older CFQ, deadline and noop schedulers were removed in kernel 5.0. Deadline-style schedulers keep separate read and write queues sorted by block number but guarantee every request a maximum wait, avoiding starvation.
RAID — redundant array of inexpensive (now independent) disks, from Patterson, Gibson and Katz's 1988 paper — combines several disks to improve performance, reliability or both. Three ideas underlie every level: striping spreads consecutive blocks across disks so they can be read in parallel; mirroring keeps an identical copy on another disk; parity stores the XOR of a stripe's data blocks so that any one lost block can be rebuilt.
| Level | Technique | Min. disks | Usable capacity (n disks) | Survives | Typical use |
|---|---|---|---|---|---|
| RAID 0 | Block-level striping, no redundancy | 2 | n (100%) | No failure at all | Speed for scratch data |
| RAID 1 | Mirroring | 2 | n/2 (50%) | 1 disk per mirror pair | OS disks, small servers |
| RAID 2 | Bit-level striping with Hamming-code ECC | — | — | 1 | Obsolete |
| RAID 3 | Byte-level striping, dedicated parity disk | 3 | n − 1 | 1 | Rare today |
| RAID 4 | Block-level striping, dedicated parity disk | 3 | n − 1 | 1 | Parity disk is a write bottleneck |
| RAID 5 | Block-level striping, distributed parity | 3 | n − 1 | 1 | General-purpose file servers |
| RAID 6 | Block-level striping, two distributed parity blocks (P + Q) | 4 | n − 2 | Any 2 | Large arrays with long rebuilds |
| RAID 10 (1+0) | A stripe across mirrored pairs | 4 | n/2 | 1 per mirror pair (up to n/2 if lucky) | Databases: speed + redundancy |
RAID 5 pays a small-write penalty: updating one block means reading the old data and old parity and writing the new data and new parity — four I/Os. RAID 4 suffers worse because every write hits its single parity disk; RAID 5 spreads the parity over all disks to remove that bottleneck. RAID 10 avoids parity altogether and is preferred for write-heavy databases. A hot spare is an idle disk that the array uses to start a rebuild automatically. RAID may be implemented by a hardware controller or in software (Linux mdadm, ZFS).
A solid-state drive (SSD) stores data in NAND flash and has no moving parts, so there is no seek time and no rotational latency; random reads are nearly as fast as sequential ones. Flash has its own peculiarities: it reads and writes in pages (a few KB) but can only erase whole blocks of many pages, and it cannot overwrite in place. A flash translation layer (FTL) inside the drive maps logical blocks to physical pages, writes new data elsewhere, and runs garbage collection to reclaim blocks full of stale pages. Each block survives a limited number of erase cycles, so the FTL performs wear levelling. The OS helps with the TRIM command (NVMe: deallocate), which tells the drive which blocks no longer hold live data.
For SSDs, seek-minimising schedulers bring little benefit, so Linux typically uses none (FCFS with merging of adjacent requests) for NVMe drives and mq-deadline for SATA SSDs. NVMe drives connect over PCIe and support many deep hardware queues — up to 64 K queues of 64 K commands each — instead of SATA's single queue of 32.
mkfs.ext4 /dev/sdb1): the superblock, free-space maps and an empty root directory.Swap space is disk space used by virtual memory as the backing store for pages. It can be a file in the normal file system (easy to resize, slower) or, more commonly on Linux, a dedicated raw swap partition managed by a swap-space manager optimised for speed rather than storage efficiency.
Try the problem first, then reveal the working one step at a time.
A disk spins at 6,000 RPM, has an average seek time of 4 ms and 400 sectors of 512 bytes per track. Find the average time to read 10 consecutive sectors, the effective bandwidth, and the time and bandwidth for reading one whole track.
Cylinders 0–199. The head is at cylinder 100 and moving toward higher cylinders. Pending requests in arrival order: 23, 89, 132, 42, 187, 145, 10, 160. Find the total head movement for FCFS, SSTF, SCAN, C-SCAN, LOOK and C-LOOK.
Six 4 TB disks are available. What usable capacity and fault tolerance does each of RAID 0, RAID 5, RAID 6 and RAID 10 give?
A disk has cylinders 0–299. It just served cylinder 100 and is now serving 140. The queue holds 65, 20, 180, 250, 120 and 135. Which of FCFS, SSTF, SCAN, C-SCAN, LOOK and C-LOOK gives the least total head movement (returns counted)?
Cylinders 0–199, head at 53. Queue: 98, 183, 37, 122, 14, 124, 65, 67. Compute total head movement for FCFS, SSTF, SCAN and LOOK (head moving toward 0), and for C-SCAN and C-LOOK (head moving toward 199).
A disk has 8 platters (both surfaces used), 16,384 tracks per surface, 1,024 sectors per track and 512-byte sectors. What is its capacity, and how many cylinders does it have?
Find the average rotational latency of a 15,000 RPM and of a 5,400 RPM disk, and the time to read one complete track on the 15,000 RPM disk.
Explain, with a concrete request pattern, how SSTF can starve a request. Which algorithms are immune, and why?
(a) Choose a RAID level: a video-editing scratch volume where speed is all and the data are disposable; a 4-disk office file server needing capacity and tolerance of one failure; a busy database needing speed and redundancy; an 8-disk archive whose rebuilds take days. (b) A stripe holds D1 = 1011, D2 = 0110 and D3 = 1100. Find the parity and rebuild D3 if it is lost.
12 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.