Friday, November 27, 2026 Independent journalism
MediaChannel

technology

What is an interrupt and how does your CPU use it?

An interrupt is the signal that lets your keyboard, network card, and storage drive demand the CPU's attention without waiting in line. Understanding how interrupts work explains why your computer can juggle dozens of tasks at once.

Detailed macro shot of a CPU microchip with focus on golden pins, highlighting technology details.

Photo by Pixabay on Pexels

Every time you press a key, your computer doesn't poll the keyboard thousands of times a second hoping to catch the input. That would be wasteful and slow. Instead, the keyboard fires an interrupt: a signal that tells the CPU to pause whatever it's currently doing, deal with the keypress, and then pick up exactly where it left off. Interrupts are the fundamental mechanism that lets a single processor appear to do many things at once.

What an interrupt actually is

An interrupt is an asynchronous signal sent to the CPU by a hardware device or by software itself. The word "asynchronous" matters here. It means the signal arrives at an unpredictable moment, independent of the instruction the CPU is currently executing. The processor finishes its current instruction, saves its working state, and jumps to a small routine called an interrupt handler (also known as an interrupt service routine, or ISR). The handler does the urgent work, then the CPU restores its saved state and continues from exactly the instruction it paused on.

Think of it like a surgeon mid-operation receiving a tap on the shoulder. The surgeon marks where they are, deals with the urgent message, and returns to the same cut. Without that mechanism, the surgeon would have to stop every few seconds to check for messages, even when there are none.

Hardware interrupts vs software interrupts

There are two broad categories, and they work quite differently.

Hardware interrupts come from physical devices: a network card signals that a packet has arrived, a storage controller signals that a read operation is complete, a timer chip fires at regular intervals to let the operating system update its clock and schedule other processes. Each device connects to the CPU through an interrupt request line (IRQ). On modern systems, a programmable interrupt controller (PIC) or its successor, the Advanced Programmable Interrupt Controller (APIC), manages these lines and decides which device gets the CPU's attention first when multiple interrupts arrive simultaneously.

Software interrupts are triggered deliberately by running code. A program calls a system interrupt instruction (such as INT on x86 processors) to ask the operating system kernel for a service, like reading a file or allocating memory. This is how user applications cross the boundary into privileged kernel space safely. The CPU treats the instruction like any other interrupt: it saves state, switches privilege level, and jumps to the kernel handler.

The interrupt vector table

The CPU needs to know which handler to call for each interrupt. It consults a structure called the interrupt vector table (IVT) on older x86 systems, or the interrupt descriptor table (IDT) on modern ones. This table is essentially an indexed list of function pointers. Interrupt number 0x21 maps to one handler, interrupt number 0x0E maps to the page-fault handler, and so on. The operating system populates this table during boot. Without it, the CPU would receive an interrupt signal and have no idea where to jump.

This is closely related to how the kernel controls your computer: the kernel owns the interrupt descriptor table, and that ownership is precisely what gives it authority over hardware. User programs cannot rewrite the IDT; only the kernel can.

Maskable and non-maskable interrupts

Not all interrupts are equal in urgency. Most hardware interrupts are maskable, meaning the CPU can temporarily ignore them by setting a flag. An operating system masks interrupts when it's executing a critical section of code that must not be interrupted mid-way, such as updating a shared data structure. Once the critical section ends, interrupts are unmasked and any pending signals are handled.

Some interrupts are non-maskable (NMIs). These signal severe hardware faults: memory errors, overheating warnings, or power failures. The CPU cannot ignore them under any circumstances. NMIs are rare in normal operation, but when they fire, the system must respond immediately or risk data corruption.

Interrupt latency and why it matters

The time between an interrupt arriving and its handler starting to execute is called interrupt latency. For most desktop software, a few microseconds of latency is irrelevant. For real-time systems, it's everything. An industrial robot controller, a cardiac monitor, or an audio interface recording live sound all have hard deadlines. Miss the deadline and the output is physically wrong: the robot arm overshoots, the audio buffer underruns and produces a click.

This is why embedded systems often use real-time operating systems (RTOS) rather than a general-purpose OS like Linux. A standard Linux kernel can defer interrupt handling across milliseconds under load. An RTOS guarantees handler execution within a bounded, predictable window. The microcontrollers inside your car's ABS braking system rely on exactly this guarantee.

Speaking of microcontrollers: microcontrollers power almost every embedded device you own, and interrupt-driven design is central to how they stay responsive while consuming minimal power. Rather than running a polling loop that burns energy checking every sensor, a microcontroller sleeps until an interrupt wakes it.

Deferred interrupt handling: top halves and bottom halves

Interrupt handlers must be fast. While a handler runs, the CPU typically can't service other interrupts, so a slow handler starves everything else. The solution is to split the work. The top half does only what's urgent: acknowledges the hardware, copies data out of the device's buffer, clears the interrupt flag. The bottom half does the heavier processing later, when interrupts are re-enabled.

Linux implements bottom halves through mechanisms called softirqs, tasklets, and work queues. Each sits at a different point on the urgency scale. A network driver's top half grabs an arriving packet from the hardware buffer. The softirq then processes the packet through the networking stack. This split keeps the top half under a microsecond while the bottom half can take as long as it needs without blocking incoming hardware signals.

How interrupts relate to concurrency bugs

Interrupts introduce a subtle form of concurrency. Even on a single-core processor, an interrupt can fire between any two instructions, effectively running two threads of execution that share memory. If the main code and the interrupt handler both touch the same variable without protection, you get a classic race. The fix is to either mask the interrupt around the shared access or use atomic operations that complete in a single, uninterruptible step.

This is the same class of problem that affects multi-threaded software more broadly. If you've read about how race conditions break software, the interrupt-driven variant is the single-core cousin of the same bug: two execution contexts colliding on shared state at an unpredictable moment.

What this means for everyday computing

Every scroll, click, and network request you make starts with an interrupt. The USB controller fires one when your mouse moves. The network card fires one when a packet arrives carrying the next video frame. The timer interrupt fires roughly 250 times per second on a standard Linux system, letting the scheduler decide whether your current process has had its fair share of CPU time.

Without interrupts, an operating system would need to dedicate entire CPU cycles to checking each device in a constant loop. With them, the CPU is free to run your code at full speed until something genuinely needs attention. It's one of the oldest and most elegant ideas in computer architecture, and it still underpins everything from your laptop to the satellites passing overhead.