Data constantly moves between devices (disk, network card, keyboard) and main memory. The question is *who does the carrying*, and how much of the CPU's time it burns. There are three answers, each freeing the CPU more than the last: programmed I/O, interrupt-driven I/O, and DMA.
Programmed I/O — the CPU does everything
The CPU itself drives the transfer. It polls the device status in a loop until the device is ready, then copies one word, then polls again for the next. Simple, but the CPU is busy-waiting — pinned to the transfer, unable to do anything useful while it spins.
Polling wastes cycles
If a device is slow to respond, the CPU may spin through millions of status checks doing no real work. Programmed I/O only makes sense for tiny, fast transfers where setting up anything fancier would cost more than it saves.
Interrupt-driven I/O — let the device call back
Instead of polling, the CPU starts the operation and goes off to run other programs. When the device is ready it raises an interrupt — a hardware signal that yanks the CPU into a short handler, which transfers the next word and returns. The CPU no longer wastes cycles waiting, but it still gets interrupted *once per word*, so a big transfer means a storm of interrupts.
DMA — hand off the whole block
Direct Memory Access adds a dedicated DMA controller that moves data between the device and memory *without* the CPU copying anything. The CPU programs the controller once with three things — source, destination, and word count — then is completely free. The controller transfers the entire block and raises just one interrupt when it is done.
1CPU tells the DMA controller: source address, destination address, and number of words.
2CPU returns to other work immediately.
3The DMA controller moves the block directly over the bus, word by word, on its own.
4When the count reaches zero, the controller raises a single completion interrupt.
5The CPU's handler runs once to note the transfer is finished.
Cycle stealing
The DMA controller and the CPU share the same memory bus, so the controller steals bus cycles when it needs them. The CPU is delayed slightly when the bus is busy, but it is never the one doing the copying — for a large transfer this is dramatically cheaper than handling every word.
Worked example — a 4 KB disk block
Moving a 4 KB block as 4-byte words means 1024 word transfers.
1Interrupt-driven: up to ~1024 interrupts, one per word — the CPU is dragged in a thousand times.
2DMA: the CPU issues one setup, the controller moves all 1024 words, and the CPU is interrupted exactly once at the end. Nearly all of that CPU time is reclaimed for real work.
OperationTimeSpace
Programmed I/O · polls + copies every wordCPU busy 100%none
Interrupt-driven · CPU free between words1 interrupt/wordnone
DMA · controller copies; CPU free1 interrupt/blockDMA controller
Check yourself
Using DMA to transfer a 1024-word block from disk to memory, how many interrupts does the CPU handle, and who copies the data?