← Back to articles
EMBEDDED SYSTEMS · PRACTICAL GUIDE

Interrupts vs. Polling vs. DMA

Polling, interrupts, and DMA solve different parts of the same problem: how software notices hardware events and moves data efficiently. They are not interchangeable features; good designs often combine them.

Polling: ask the device repeatedly

In polling, the CPU reads a status register or checks a condition in a loop. It is simple, predictable, and useful during early bring-up or when events are extremely frequent and cheap to check. The downside is wasted CPU time and the possibility of missing timing goals when the loop is delayed.

while (!(REG_STATUS & RX_READY)) {
    /* wait, perhaps with a timeout */
}

Production code should normally include a timeout or another escape path instead of waiting forever.

Interrupts: let the device signal an event

An interrupt allows hardware to notify the CPU when attention is required. The interrupt handler should usually acknowledge or capture the minimum necessary state, then defer longer work to a threaded handler, tasklet/workqueue, or RTOS task as appropriate. Keep interrupt context short and avoid sleeping in a hard interrupt handler.

DMA: move data without copying every byte in the CPU

DMA engines transfer blocks between a peripheral and memory. The CPU configures the transfer and handles completion, often through an interrupt. DMA reduces per-byte CPU work but adds buffer ownership, alignment, addressability, and cache-coherency requirements.

They work together

A common UART design uses interrupts for small or irregular traffic and DMA for larger buffers. A network interface may use DMA descriptor rings and interrupts, with polling in a budgeted receive loop. A boot-time driver may poll briefly before the scheduler or interrupt controller is ready.

Decision checklist

The best choice depends on peripheral behavior, operating system, data rate, and real-time requirements. Consult the chip manual and OS driver model.

Final takeaway

Low-level engineering is about understanding the contract between hardware, firmware, and the operating system. Start with the specification, form a testable hypothesis, collect evidence, and validate behavior on the target platform.