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.

AspectPollingInterrupt
How it worksThe CPU repeatedly reads a status register to see whether the device is readyThe device raises a signal; the CPU suspends its work and runs an interrupt handler (ISR)
CPU use while waitingBusy: the CPU spends cycles checkingFree: the CPU can do other work or sleep
Response timeSet by how often the loop checks; predictableFast (microseconds), but varies with masking, priority and context saving
OverheadConstant, even when nothing happensA cost per event; a very high event rate can overwhelm the CPU (interrupt storm)
ComplexitySimple to write and debugMore complex: handlers must be short, and shared data with the main code needs care (volatile, atomic access)
PowerKeeps the CPU awakeAllows low-power sleep until an event wakes the CPU
Timing behaviorEasy to reason aboutConcurrency bugs are possible between handler and main code
Typical usesVery fast or continuous events, simple programs, high-speed networking driversTimers, buttons, communication events, sensor alerts, waking from sleep

Figures are typical orders of magnitude and vary by process generation and product.

When to use which

Polling
When events are frequent or the loop is simple, and you want predictable timing without handler complexity.
Interrupt
When events are rare or unpredictable, you want a quick response and low power, and the CPU has other work to do.
Hybrid
Some systems combine them: an interrupt announces the first event, and the driver then polls while traffic is heavy, as in high-speed network drivers.

FAQ

Which is better, interrupts or polling?

Neither always. Interrupts give a fast response and let the CPU sleep, while polling is simple and predictable. Use interrupts for rare events and polling for very frequent ones.

What should an interrupt handler do?

Be short: do the minimum, set a flag or queue the work, and return. Long work or blocking calls inside a handler hurt responsiveness.

What is an interrupt storm?

When events arrive so fast that the CPU spends all its time entering and leaving handlers. High-speed network drivers switch to polling in that case.

Why do interrupts save power?

The CPU can sleep until an event wakes it, instead of waking up constantly to check.

Check your understanding

What is the difference between polling and interrupts as ways to learn a peripheral's status?

  1. AWith polling the CPU checks the status repeatedly; with interrupts the peripheral notifies the CPU when the status changes
  2. BPolling and interrupts are the same thing
  3. CInterrupts are the method where the CPU repeatedly checks the status
Show answer and explanation

Answer: A. With polling the CPU checks the status repeatedly; with interrupts the peripheral notifies the CPU when the status changes

Polling is simple and predictable because checks happen at fixed intervals, but the CPU keeps checking even when nothing happens, wasting time and power. With interrupts the CPU responds only when something changes, so it can do other work or sleep while waiting. If interrupts are extremely frequent, though, their overhead becomes large, so the choice matters.

What should be avoided inside an interrupt handler?

  1. AWriting 1 to a flag variable to notify the main code
  2. BClearing the bit that indicates the interrupt source
  3. CTime-consuming work such as printing long strings with printf or loops that wait for something to happen
Show answer and explanation

Answer: C. Time-consuming work such as printing long strings with printf or loops that wait for something to happen

While an interrupt handler runs long, other interrupts cannot be serviced and the main code stalls. printf takes time to finish and may itself rely on interrupts, so it is especially risky. A handler should do only the minimum, such as moving received data into a buffer or setting a flag, and leave heavy work to the main loop or a task. It must also remember to clear the interrupt source bit.

On a microcontroller with interrupt priorities, a higher-priority interrupt occurs while a lower-priority handler is running. What generally happens (assuming nesting is allowed)?

  1. AThe low-priority handler is suspended, the high-priority handler runs, and then the low one resumes
  2. BThe high-priority interrupt is discarded until the low handler finishes
  3. CBoth handlers execute in parallel on the same CPU at once
Show answer and explanation

Answer: A. The low-priority handler is suspended, the high-priority handler runs, and then the low one resumes

With interrupt priorities, an urgent interrupt is serviced even while another handler is running. For example, if motor overcurrent detection has high priority and communication reception low priority, overcurrent can be handled at once even mid-reception. Arm Cortex-M's NVIC and others provide this mechanism. Interrupts of equal or lower priority wait until the current handler finishes.

  1. Why is interrupt handling split into a short part done immediately and the remainder done later in a normal context?
  2. While the main code updates a register bit with "reg |= mask;" (read-modify-write), an interrupt handler changes a different bit of the same register. Which pairs the possible problem with a fix correctly?
  3. A timer counts a 16 MHz clock divided by 16 with a prescaler and raises an interrupt every 1000 counts. What is the interrupt interval?

Practice Embedded Systems & Firmware questions

Key terms explained

Interrupt
A CPU mechanism that temporarily suspends the current task to handle a request, for example from an external device, and then returns to the original task.
Polling
A method in which the CPU repeatedly checks a peripheral's status to detect changes. Simple, but it consumes time and power even when nothing happens.
Interrupt handler
The routine a CPU runs when an interrupt or exception occurs. It saves the interrupted state, handles the cause and returns. Handlers should be kept as short as possible.

Related comparisons