What is 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.

Field: Embedded Systems & Firmware

Japanese name: ポーリング

How polling works

With polling, the CPU learns about a peripheral by reading its status register in a loop, for example checking a UART's "receive data ready" flag until it is set and then reading the byte. The check may be a tight busy-wait or a periodic test inside the main loop or a timer routine. Polling is simple to write and debug, and the timing is predictable because checks happen exactly where the program places them. In C, the register pointer must be declared volatile so the compiler actually re-reads the hardware on each pass instead of reusing a cached value.

Polling vs. interrupts

With interrupts, the peripheral signals the CPU when something happens; the CPU suspends its current work, saves its state, runs a handler and resumes. That leaves the CPU free to do other work or sleep while waiting, which matters for battery-powered devices. Polling spends CPU time and energy even when nothing has changed, and its worst-case reaction time is set by the polling interval. Each interrupt, on the other hand, carries fixed overhead for entering and leaving the handler, which polling avoids.

When polling is the better choice

Polling wins when events are so frequent that per-interrupt overhead would dominate. High-speed network processing is the classic case: under heavy load, drivers switch from an interrupt per packet to polling batches of packets, and some packet-processing frameworks dedicate cores to continuous polling. Polling also suits very short waits, such as a status flag that will be ready within a few cycles, simple boot code where interrupts are not yet configured, and control loops that must sample at strictly fixed instants.

Hybrid approaches

Real systems often combine the two. An interrupt wakes the CPU from sleep, and the handler then polls to drain all pending data before re-enabling the interrupt, so a burst of events costs one interrupt rather than many. DMA (direct memory access) reduces the need for either by moving data without CPU involvement and signalling only when a whole block is complete. Care is needed with status registers whose flags are cleared by the act of reading them, because an extra read can silently discard an event.

Try it: questions about Polling

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.

FAQ

What is the difference between polling and interrupts?

With polling, the CPU repeatedly checks a device's status; with interrupts, the device notifies the CPU when its status changes. Polling is simpler and predictable, while interrupts let the CPU do other work or sleep in the meantime.

Why should a polled register be declared volatile in C?

Without volatile, the compiler may assume the value cannot change and read it only once, turning the polling loop into an infinite loop. Volatile forces a fresh read of the hardware register on every iteration.

Is polling always inefficient?

No. When events arrive at a very high rate, polling avoids the save-and-restore overhead of each interrupt and can process events in batches, making it more efficient than interrupts.

Questions that mention Polling (1)

Polling appears in 2 practice questions across 2 topics, including Embedded Systems & Firmware, CPUs and architecture.

  1. Which CPU mechanism temporarily suspends the current task to give priority to handling requests such as those from external devices?

Books on Embedded Systems & Firmware Ad

Learn hands-on: parts and kits

Building real circuits is a good way to check what you learned in the questions.

As an Amazon Associate I earn from qualifying purchases.

Comparisons that include this term

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary