Interrupt vs Polling: Differences and When to Use Each
There are two ways for a processor to learn that a device needs attention. With polling, the CPU keeps checking the device status in a loop. With interrupts, the device signals the CPU, which pauses what it is doing, runs a small handler and then resumes. Polling is simple and predictable but wastes time; interrupts are efficient and responsive but add overhead and make the program harder to reason about.
| Aspect | Polling | Interrupt |
|---|---|---|
| How it works | The CPU repeatedly reads a status register to see whether the device is ready | The device raises a signal; the CPU suspends its work and runs an interrupt handler (ISR) |
| CPU use while waiting | Busy: the CPU spends cycles checking | Free: the CPU can do other work or sleep |
| Response time | Set by how often the loop checks; predictable | Fast (microseconds), but varies with masking, priority and context saving |
| Overhead | Constant, even when nothing happens | A cost per event; a very high event rate can overwhelm the CPU (interrupt storm) |
| Complexity | Simple to write and debug | More complex: handlers must be short, and shared data with the main code needs care (volatile, atomic access) |
| Power | Keeps the CPU awake | Allows low-power sleep until an event wakes the CPU |
| Timing behavior | Easy to reason about | Concurrency bugs are possible between handler and main code |
| Typical uses | Very fast or continuous events, simple programs, high-speed networking drivers | Timers, buttons, communication events, sensor alerts, waking from sleep |
Figures are typical orders of magnitude and vary by process generation and product.