Skip to content
Tutorials Center
My learning

Topics

Lesson 53 of 66 ยท I/O and Disk Scheduling

Disk Structure and Access Time

Understand hard disk geometry (platters, tracks, sectors), seek time, rotational latency and transfer time, how SSDs differ, and calculate disk access time with Python.

Almost every file you open, every page swapped in and every database row ends up on a storage device. The OS cannot manage that traffic well without a mental model of the hardware, so before studying disk scheduling we look at how a disk is built and where the time goes when you read a block. Two device families matter today: the hard disk drive (HDD) with moving parts, and the solid-state drive (SSD) made of flash chips.

Inside a hard disk drive

An HDD is a stack of rigid, rotating platters coated with magnetic material. Each surface has its own read/write head on an arm, and all arms move together as one unit (the actuator).

  • A track is one circle on a surface.
  • All tracks at the same arm position, on every surface, form a cylinder.
  • Each track is divided into sectors, the smallest unit the drive reads or writes (traditionally 512 bytes, now often 4,096).
  • Platters spin at a constant speed, for example 5,400 or 7,200 revolutions per minute (RPM).
flowchart TD
    A["Spindle motor<br/>spins the platters"] --> P["Platter surfaces"]
    P --> T["Tracks (circles)"]
    T --> S["Sectors (arcs of a track)"]
    AR["Actuator arm + heads"] -->|"moves to a cylinder"| T

The arm chooses the track; the rotation brings the right sector under the head.

The OS used to address sectors by CHS (cylinder, head, sector). Modern drives hide their geometry and present a flat array of numbered blocks, LBA (logical block addressing). The drive firmware maps LBAs to the physical layout, remaps bad sectors, and the OS assumes that nearby numbers are physically close.

The three parts of access time

Reading a sector on an HDD has three delays that add together:

  1. Seek time: moving the heads to the right cylinder. This is the slowest part, typically 1-10 ms depending on distance. Zero if the head is already there.
  2. Rotational latency: waiting for the target sector to rotate under the head. On average half a revolution: 0.5 x 60,000 / RPM milliseconds. At 7,200 RPM one rotation takes 8.33 ms, so the average wait is 4.17 ms.
  3. Transfer time: reading the bytes as they pass under the head: bytes / transfer rate.
TEXT
Disk access time = seek time + rotational latency + transfer time

For a random 4 KB read, seek and rotation dominate (around 10 ms), and transfer is a few microseconds. That is why sequential access (no seeking, no waiting) can be 100 times faster than random access, and why the OS works so hard to turn random requests into sequential ones. That work is the subject of the next lesson on disk scheduling.

Python Calculate average disk access time

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A hard disk does roughly 75-100 random reads per second, yet streams data at 150 MB/s or more when reading sequentially.

Seek distance and track layout

Seek time grows with the number of tracks the arm must cross, roughly in proportion (with a startup cost: acceleration and settling). If the arm moves from track 53 to track 98 that is 45 tracks of travel. All the disk scheduling algorithms try to reduce the sum of such distances.

Other structural facts that affect performance:

  • Zoned bit recording: outer tracks are longer, so they hold more sectors and pass more data per revolution. Low LBAs (outer tracks) transfer faster than high LBAs.
  • Track skew and interleaving: sector numbering is offset between tracks so that when the head switches tracks the next sector arrives just as the head is ready.
  • Command queueing: modern drives (NCQ, TCQ) accept many requests and reorder them internally, using the drive's own knowledge of where sectors really are.

Solid-state drives

An SSD has no moving parts. Data lives in NAND flash chips organized as:

  • pages (typically 4-16 KB), the smallest unit that can be read or programmed,
  • blocks (hundreds of pages), the smallest unit that can be erased.

Flash cannot overwrite a page in place. To change data, the drive writes the new version to a fresh page and marks the old one stale. When a block is mostly stale, garbage collection copies the live pages elsewhere and erases the block. A Flash Translation Layer (FTL) keeps a map from logical to physical pages. Since flash cells wear out after a limited number of erases, the FTL also spreads writes evenly (wear levelling).

Consequences for the OS:

  • No seek time and no rotational latency, so access time is tens to hundreds of microseconds and random reads are nearly as fast as sequential ones.
  • TRIM tells the drive which blocks the file system freed, so garbage collection need not copy dead data.
  • Write amplification and endurance matter; the OS avoids unnecessary writes.
  • Elevator-style scheduling brings little benefit; many systems use a simple none or mq-deadline scheduler for SSDs.
HDD SSD
Random read latency ~5-12 ms ~0.05-0.2 ms
Sequential throughput 100-250 MB/s 500-7,000 MB/s
Moving parts Yes No
Cost per GB Lowest Higher
Wear Mechanical Limited erase cycles
Seek-minimising scheduling Very useful Rarely useful

Estimating whole workloads

Total time for many requests is the sum of their individual costs. A small model that follows the arm position shows why order matters.

Python Arm travel and total time for a request list

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Same six requests, a fraction of the arm travel, simply by serving them in a smarter order.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which component is usually the slowest part of a random HDD read?

    Moving the arm and waiting for the sector to rotate under the head take milliseconds. Transferring a 4 KB block takes microseconds.
  2. 2. What is the average rotational latency of a 6,000 RPM disk?

    One revolution takes 60,000 / 6,000 = 10 ms. On average the head waits half a turn, which is 5 ms.
  3. 3. What is a cylinder?

    Because all heads move together, the tracks they can reach without moving the arm form a cylinder.
  4. 4. Why does an SSD need TRIM?

    Flash cannot overwrite in place. Knowing which pages are unused lets the SSD erase blocks without copying useless data.

Summary

  • An HDD has platters, tracks, sectors and cylinders; modern drives expose numbered blocks (LBA).
  • Access time = seek time + rotational latency + transfer time; seek and rotation dominate random access.
  • Sequential access is far faster than random on an HDD, so the OS reorders requests.
  • SSDs use flash with a translation layer, garbage collection, wear levelling and TRIM, and have no seek cost.

Next: Disk Scheduling Algorithms