Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Session 5.1: I/O device management, disk structure and RAID

How the kernel talks to devices (polling, interrupts, DMA, buffering, caching, spooling), how a disk is organised and timed, and how RAID levels trade capacity for speed and reliability.

Module 5 1.5 hours Theory CO5
← Before
4.8 Directories & allocation
End of Module 4
You are here
5.1 I/O device management, disk structure and RAID
Module 5 · Managing Devices, Security, Protection and Virtualization
Next →
5.2 Disk scheduling
FCFS … C-LOOK

Learning objectives

By the end of this session you should be able to:

  • Describe the layers of the I/O subsystem and compare polling, interrupts and DMA.
  • Explain buffering, caching and spooling.
  • Describe disk geometry and compute seek, rotational latency and access time.
  • Explain striping, mirroring and parity, and compare RAID levels 0–6 and 10.
  • Compute usable capacity and fault tolerance for a RAID configuration.

Lecture notes

1. I/O device management basics

Devices vary enormously — keyboards deliver a few bytes per second, NVMe SSDs gigabytes. The OS hides this variety behind a layered I/O subsystem:

User process — read(), write()
Kernel I/O subsystem — scheduling, buffering, caching, spooling, error handling
Device drivers — one per device type, a uniform interface upward
Device controllers — registers, buffer, on the bus
Devices
Polling

The CPU repeatedly reads the controller's busy bit. Fine if the device is fast; wasteful otherwise.

Interrupt-driven I/O

The controller raises an interrupt when done (Session 1.4). The CPU works on something else meanwhile.

DMA

For bulk transfers the CPU programs a DMA controller with source, destination and count; the controller moves the whole block and interrupts once.

Buffering

Memory holding data in transit — copes with speed mismatch (modem → disk) and size mismatch; double buffering lets one buffer fill while the other is written.

Caching

Keeps copies of data in faster storage (the page cache) so repeated reads avoid the device.

Spooling

A buffer for a device that cannot interleave jobs (a printer): output is queued on disk and printed one job at a time.

2. Disk structure

A hard disk drive (HDD) has several platters, each with two surfaces covered by concentric tracks divided into sectors (512 bytes or 4 KB). The set of tracks at one arm position across all platters is a cylinder. A read–write head on an arm floats over each surface.

tracksectorarm + head
Disk access time

\[ \text{access time} = \text{seek time} + \text{rotational latency} + \text{transfer time} \]

  • Seek time — move the arm to the cylinder (several ms; the dominant cost).
  • Rotational latency — wait for the sector to rotate under the head. Average = half a rotation: at 7200 RPM one rotation is 60/7200 s = 8.33 ms → average 4.17 ms.
  • Transfer time — move the data; small for one sector.

The disk is addressed as a large one-dimensional array of logical blocks, mapped onto sectors in order (track by track, cylinder by cylinder). SSDs (flash) have no moving parts — no seek or rotational latency — so disk scheduling matters far less for them; they instead wear out with writes and need wear-levelling.

Before use a disk is low-level formatted (sectors with headers and error-correcting codes), partitioned, and logically formatted (a file system is created — Module 4). One partition holds the boot block (Session 1.4).

3. RAID — Redundant Array of Independent Disks

Many cheap disks can be organised for performance (read and write in parallel by striping data across disks) and reliability (survive a disk failure through redundancy: mirroring or parity). With 100 disks each having a mean time to failure of 100 000 hours, some disk fails every 1000 hours (~42 days) — redundancy is essential.

Striping, no redundancy. Block 0 → disk 0, block 1 → disk 1, … Fastest and uses 100% of capacity, but one failure loses everything.

D0: A1 A3 A5D1: A2 A4 A6

Mirroring. Every block is written to two disks. Survives one disk failure; reads can use either copy; 50% capacity.

D0: A1 A2 A3D1: A1 A2 A3

RAID 2: bit-level striping with Hamming-code ECC disks (obsolete). RAID 3: byte/bit-interleaved data plus a single parity disk; the controller can rebuild any one failed disk from the others' parity.

Block-level striping + a dedicated parity disk. Parity P = A1 ⊕ A2 ⊕ A3 (XOR). If a disk fails, its block = XOR of the survivors. Problem: every write updates the single parity disk — a bottleneck.

D0: A1 B1D1: A2 B2D2: A3 B3D3: Ap Bp

Block-level striping with distributed parity. Parity blocks are spread across all disks, removing RAID 4's bottleneck. Survives one failure; capacity (n − 1)/n. The most common parity RAID.

D0: A1 B1 CpD1: A2 Bp C1D2: Ap B2 C2

P + Q redundancy. Like RAID 5 with a second, independent parity — survives two simultaneous failures (important for large disks with long rebuild times). Capacity (n − 2)/n.

Nested RAID. RAID 1+0 (RAID 10) mirrors pairs of disks and then stripes across the pairs — high performance and reliability, 50% capacity; preferred for databases. RAID 0+1 stripes first then mirrors the stripes.

Parity in one line

Data blocks 1011, 0110, 1100 → parity = 1011 ⊕ 0110 ⊕ 1100 = 0001. If the disk holding 0110 dies: 1011 ⊕ 1100 ⊕ 0001 = 0110 — recovered.

LevelTechniqueUsable capacity (n disks)Failures survivedTypical use
0Stripingn0Scratch space, video editing
1Mirroringn/21 per mirrorOS disks, small servers
5Striping + distributed parityn − 11File servers
6Striping + double parityn − 22Large archives
10Mirror + stripen/21 per mirror pairDatabases

Example: six 4 TB disks give 24 TB in RAID 0, 12 TB in RAID 1/10, 20 TB in RAID 5, 16 TB in RAID 6.

VideoBytes

I/O management and disk structure

Video coming soon

I/O management and disk structure

Recorded by Dr. Krithika L.B. Slot m5-io-disk

RAID levels

Video coming soon

RAID levels

Recorded by Dr. Krithika L.B. Slot m5-raid

Interactive lessons

Work through these in order after the lecture — each one expands a part of the notes with diagrams, hover notes and a quick check.

Lab connection

Check your understanding

Answer each question in your own words first, then reveal the model answer.

Revealed 0
A disk spins at 5400 RPM. What is the average rotational latency?

One rotation = 60/5400 s = 11.11 ms → average = 5.56 ms.

Why use DMA instead of interrupt-driven I/O for a disk?

Interrupting the CPU for every byte or word would waste it; DMA moves a whole block and interrupts once.

What is the difference between a buffer and a cache?

A buffer may hold the only copy of data in transit; a cache holds a copy of data that also exists elsewhere, to speed up access.

Five 2 TB disks in RAID 5: usable capacity and failures tolerated?

(5 − 1) × 2 = 8 TB; one disk failure.

Why does RAID 5 perform better on writes than RAID 4?

Parity is distributed over all disks, so parity updates do not all hit one dedicated parity disk.

Key takeaways

  • I/O: drivers hide devices; polling, interrupts and DMA move data; buffering, caching and spooling smooth it.
  • Disk access = seek + rotational latency + transfer; seek dominates on HDDs.
  • RAID: 0 striping, 1 mirroring, 5 distributed parity, 6 double parity, 10 mirror + stripe.

Where this leads

Seek time dominates HDD access. With many requests waiting, the order in which we serve them decides how far the arm travels. Next: disk-scheduling algorithms.

Continue to 5.2 — Disk scheduling algorithms →