Learning path

Full curriculum

Full curriculum

Unit content

Hardware interrupts

Polling requires software to keep checking whether an event happened. A hardware interrupt lets a device or peripheral request processor attention asynchronously.

When an interrupt is accepted, the processor preserves enough execution state to transfer control to an interrupt handler associated with that interrupt source. After the handler finishes, ordinary execution can resume.

A processor may support interrupt priorities, masking and nesting. These mechanisms determine which events can interrupt others and how long a high-priority event may wait before its handler begins.

An interrupt handler executes because of an external event, not because the current code called it. Shared state can therefore be observed at unexpected points in ordinary execution.

The exact privilege change depends on the architecture: an operating system may enter privileged kernel code, while a small microcontroller may run both ordinary firmware and the handler at the same privilege level.

Interrupts trade polling overhead for asynchronous control flow and introduce timing and concurrency that software must handle explicitly.