8.3I/O transfer: polling, interrupts and DMA
The idea
I/O transfer methods: polling (CPU keeps checking), interrupts (device signals) and DMA (controller moves the whole block).
Think of it like this: Checking the oven every minute (polling), being told by a timer (interrupt), or having a helper carry the whole tray to the table and call you once (DMA).
Why it exists
The CPU is expensive; the less time it spends moving bytes, the more useful work it does.
How it works
- Polling: CPU busy-waits on the status register.
- Interrupt: one interrupt per word or byte, CPU moves the data.
- DMA: the CPU programs the controller (address, count) and carries on; one interrupt at the end.
- DMA steals memory cycles from the CPU: cycle stealing.
Worked example: A device sends 500 KB/s in 4-byte words, memory cycle 100 ns
128 000 words per second, each stealing one 100 ns cycle: 12.8 ms per second, about 1.3% of the bus time.
Now play with it
- →Use the DMA calculator with a faster device.
- →Read the table for when each method fits.
| Method | CPU involvement | Bus use | Best for |
|---|---|---|---|
| Programmed I/O (polling) | CPU loops on the status register | CPU moves every word | tiny, fast devices where waiting is short |
| Interrupt-driven | one interrupt per word or byte | CPU moves every word | slow character devices (keyboard) |
| DMA | one interrupt per block | controller steals bus cycles | disks and networks, large transfers |
Cycle stealing: each word moved by DMA holds the memory bus for one cycle, so the CPU slows slightly.
Check yourself
In DMA, the CPU is interrupted
Exam notes (the dense version)
Programmed I/O (polling): the CPU repeatedly checks the device status: simple but wastes CPU. Interrupt-driven I/O: the device signals when ready; the CPU does other work but takes an interrupt per byte or word. DMA: a controller moves a whole block between device and memory without the CPU, interrupting once at the end; it steals bus cycles (cycle stealing). Cycle-stealing percentage = DMA time ÷ total time. Use DMA for big, fast transfers and interrupts for slow character devices.
Previous year questions: Disk Scheduling & I/O (12)
PYQs are grouped by topic, so this is the full set for Disk Scheduling & I/O; try the ones that match this subtopic. Open all 12 on the topic page.