DMA vs Programmed I/O: Differences Explained
There are two ways to move data between a device and memory. In programmed I/O (PIO), the CPU itself reads or writes every word through registers. In direct memory access (DMA), a DMA controller moves the data on its own, and the CPU only sets up the transfer and is notified when it is done. DMA frees the CPU and handles large transfers much faster, but it needs more setup and care.
| Aspect | Programmed I/O (PIO) | DMA |
|---|---|---|
| Who moves the data | The CPU, word by word, with load and store instructions | A DMA controller or the device itself, directly to or from memory |
| CPU load | High: the CPU is busy during the whole transfer | Low: the CPU sets up the transfer and does other work |
| Throughput for large transfers | Limited by the CPU speed | High |
| Setup overhead | None | Needs an address, a length or descriptors, and completion handling |
| Small transfers | Often faster, because there is no setup | The setup cost can outweigh the benefit |
| Complexity | Simple | More complex: descriptor rings, buffer alignment, cache coherency and IOMMU settings |
| Memory bus use | Through the CPU | The DMA engine competes with the CPU for memory bandwidth |
| Typical uses | Small control registers, simple sensors, legacy PIO modes | SSDs and NVMe, network cards, audio buffers, ADC sample streams, GPU transfers |
Figures are typical orders of magnitude and vary by process generation and product.