← Operating System Concepts

BOOK NOTES · OPERATING SYSTEMS · CHAPTER 11

Operating System Concepts Chapter 11 — Mass-Storage Structure.

operating-systemschapter-11storagedisk-schedulingraidssd

// the one-minute version

Persistent storage holds data when the power's off. Hard disks are mechanical — a head seeks across spinning platters, so request order matters and the OS uses disk scheduling (SSTF, SCAN, C-SCAN) to cut seek time. SSDs have no moving parts, so scheduling matters far less but writes wear cells out. RAID combines drives for speed, redundancy, or both — but it isn't a backup.

RAM forgets everything when you unplug. Storage is where your files survive. But storage is also achingly slow compared to RAM — especially the spinning kind — so a lot of OS cleverness goes into ordering and arranging disk work to hide that slowness.

01 Hard disks: mechanical and order-sensitive

A hard disk has spinning platters, organized into tracks (concentric rings) and sectors, and a read/write head on a moving arm. To read a block the head must seek to the right track (the slowest part), then wait for rotational latency as the platter spins the data under it, then transfer. Seek time dominates and depends on where the head is now — so the order you service requests changes total time dramatically.

02 SSDs: electronic and different

A solid-state drive stores data in flash with no moving parts. No seek, so random access is roughly as fast as sequential, and disk-scheduling tricks barely help. But flash cells wear out after many write/erase cycles, so SSDs add wear leveling to spread writes evenly. And flash can't overwrite in place — it must erase a whole block first, so a separate garbage collector and the TRIM command manage free space. A different cost model entirely.

Hard disk (HDD)Solid-state (SSD)
Moving partsyes (platters, head)none
Random accessslow (seek + rotation)fast
Scheduling mattersa lotvery little
Main wear concernmechanical failurelimited write cycles
Cost per GBcheaperpricier

03 Disk scheduling

When several disk requests are pending, the OS picks the order. On an HDD a smart order means far less head travel:

FCFS

Serve in arrival order. Fair but the head can bounce wildly across the disk, wasting seeks.

SSTF — shortest seek time first

Always serve the nearest request next. Good throughput, but distant requests can starve, and it's a bit like SJF for disks.

SCAN (elevator)

The head sweeps in one direction servicing requests, then reverses — like an elevator. Smooth, no wild jumps, no starvation.

C-SCAN

Like SCAN but always sweeps the same direction, snapping back to the start at the end. More uniform wait times across the disk.

think of it likeDisk scheduling is an elevator's logic. A good elevator doesn't chase button-presses in order pressed — it sweeps up servicing every request, then down. SCAN is literally called the elevator algorithm for this reason.
noteOn an SSD, all of this mostly evaporates: with no seek penalty, request order barely affects performance. Disk scheduling is a story about mechanical storage and matters less every year as SSDs take over — but the elevator idea is a classic worth knowing, and it still appears in exams.

04 RAID: many drives, one goal

RAID (redundant array of independent disks) combines drives for speed, reliability, or both. Two core techniques combine into the levels: striping (split data across drives for parallel speed), mirroring (duplicate data for safety), and parity (store redundancy that can rebuild a lost drive).

LevelTechniqueGives you
RAID 0stripingspeed — but zero redundancy; one drive dies, all data lost
RAID 1mirroringredundancy — survives a drive failure; costs double the disks
RAID 5striping + distributed paritygood speed + survives one drive failure, efficient on space
RAID 6striping + double paritysurvives two simultaneous drive failures
RAID 10mirror + stripespeed and redundancy; expensive (half capacity)
watch outRAID is not a backup. RAID 1/5/6 protect against drive hardware failure, but they happily replicate a deleted file, a ransomware encryption, or a bad write to every disk instantly. You still need real, separate backups for human error, corruption, and disasters.

05 Swap space

Storage also backs virtual memory: swap space is the disk area where the OS parks pages evicted from RAM (Chapter 10). Because swapping touches the disk, fast swap storage matters and keeping swapping rare matters more — heavy swapping is exactly the thrashing that wrecks performance. (An SSD makes swap far less painful than a spinning disk, but it's still vastly slower than RAM.)

common catches & gotchas

  • Order matters only on HDDs — Disk scheduling is a mechanical-disk story. On SSDs it buys almost nothing — don't apply HDD intuition to flash.
  • RAID ≠ backup — The single most dangerous misconception in storage. RAID survives a dead drive, not a deleted file or ransomware. Keep real backups.
  • RAID 0 has no redundancy — Despite the name, RAID 0 makes you more likely to lose data — any one drive failing loses everything. It's pure speed.
  • SSDs wear out — Flash cells die after enough writes. Write-heavy workloads on cheap SSDs fail sooner than people expect; wear leveling only delays it.
  • SSTF can starve — Always picking the nearest request can leave far-away requests waiting forever — same starvation risk as SJF. SCAN avoids it.

06 Questions students actually ask

Why does request order matter so much on a hard disk?

Because the mechanical head must physically seek to each location, and seek time dominates. Servicing nearby requests together (instead of in arrival order) drastically cuts total head travel.

Why doesn't disk scheduling help SSDs much?

SSDs have no moving head and no seek penalty, so a random block is about as fast as a sequential one. Reordering requests for locality — the whole point of scheduling — buys almost nothing.

Is RAID a substitute for backups?

No. RAID protects against drive hardware failure but instantly mirrors mistakes — deletions, corruption, ransomware — onto every disk. Backups protect against those; RAID protects against a dead drive. You need both.

What is swap space?

Disk space the OS uses to hold memory pages evicted from RAM under virtual memory. It lets the system pretend to have more RAM than it does, at the cost of slow disk access when those pages are needed again.

Why do SSDs need wear leveling and TRIM?

Flash cells survive a limited number of writes and can't overwrite in place. Wear leveling spreads writes evenly to prolong life; TRIM tells the drive which blocks are free so it can erase and reuse them efficiently.

07 Key takeaways

  • Storage persists data without power but is far slower than RAM.
  • HDDs are mechanical, so request order (disk scheduling) hugely affects speed; seek time dominates.
  • SSTF/SCAN/C-SCAN reduce head travel; SCAN avoids the starvation SSTF can cause.
  • SSDs have no seek, so scheduling barely matters, but writes wear cells out (wear leveling, TRIM).
  • RAID combines drives for speed (0), redundancy (1), or both (5/6/10) — but isn't a backup.
  • Swap space on disk backs virtual memory; heavy swapping = thrashing.

08 Wrapping up

Now you know the physical storage devices and how the OS schedules them. Next: the layer that lets the CPU talk to all devices — disks, keyboards, networks — uniformly. Next up: I/O Systems.

← prev: Chapter 10next: Chapter 12 →
© cvam — written in plaintext, served warm