How Does a Hardware Interrupt Get the CPU’s Attention?

Hands probing connected processor and peripheral boards on an electronics workbench

Hardware Interrupt Explainer

A hardware interrupt is a device’s way of asking a processor for attention without forcing the processor to check that device constantly. A keyboard can signal that a key arrived, a network adapter can report completed packets, and a timer can announce that a time slice has ended. The signal does not usually make the CPU abandon its work at an arbitrary electrical instant. Instead, the processor finishes an instruction at a safe boundary, checks whether the request is eligible, and then transfers control to code prepared to handle that kind of event. Interrupts therefore connect unpredictable activity in the physical machine to an orderly software response.

The request normally passes through an interrupt controller before reaching a CPU core. The controller records pending events, assigns priorities, applies masks, and decides which core should receive each request. Older devices often asserted a dedicated line, while modern peripherals may send a small message over an interconnect, a method commonly called a message-signaled interrupt. Either form identifies an interrupt source or number. Software configures the controller so urgent events can outrank routine ones and temporarily disabled sources can wait. This routing layer matters on multicore systems, where sending every event to one core would create a bottleneck even when other cores are available.

When the CPU accepts an interrupt, it preserves enough execution state to resume the interrupted program later. It changes to a privileged execution context, consults an interrupt vector that points to the proper handler, and begins running an interrupt service routine. The handler acknowledges the controller or device so the same request is not delivered forever. It then performs the minimum time-sensitive work, such as reading a status register or recording which buffer finished. Finally, a special return instruction restores the saved state, allowing the earlier program to continue as though it had only paused for a short, carefully managed detour.

Good interrupt handlers stay brief because other work may be waiting and some interrupts may be temporarily blocked while a handler runs. Operating systems commonly split the response into two stages. The immediate stage captures essential facts and schedules a deferred task; the later stage performs heavier processing such as moving packet descriptions through a networking stack. Edge-triggered requests report a transition, while level-triggered requests remain asserted until their cause is cleared, so acknowledgment rules differ. Shared interrupt lines also require software to inspect devices and discover which one actually raised the request. These details prevent lost events, repeated events, and long stalls.

Interrupts introduce concurrency because a handler can run between almost any two instructions of ordinary code. Data shared with that handler must be protected with suitable locks, atomic operations, or short periods in which a source is masked. Devices that produce work rapidly often combine interrupts with direct memory access: the device moves data to memory, then interrupts only when a batch is ready. Drivers may also use interrupt moderation to group many completions into fewer notifications. Without those controls, an interrupt storm can consume most CPU time. Excessive masking causes the opposite problem by increasing latency and risking overfilled device queues.

The practical advantage is efficiency. Polling every peripheral in a tight loop can respond quickly, but it burns processor time and power when nothing has happened. Interrupts let the CPU run applications, enter a low-power state, or serve other devices until attention is actually required. High-performance systems sometimes mix both approaches, using an interrupt to announce activity and then polling briefly while traffic stays heavy. The important idea is not that an interrupt performs the whole job. It is a prioritized notification that moves the processor into a known handler, records the event safely, and returns control with as little disruption as possible.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.