Interrupt-driven I/O is an input/output technique in which a device notifies the CPU with a hardware interrupt when it has finished an operation or needs attention, instead of the processor repeatedly checking the device’s status. In operating systems, it is the foundation of how drivers & devices cooperate: the CPU starts an I/O request, switches to other work and returns to the device only when the device signals that data is ready.
The technique sits between two other approaches. Programmed I/O with polling wastes CPU cycles on status checks, while direct memory access (DMA) moves whole blocks of data without the CPU. Interrupt-driven I/O removes the busy waiting of polling but still has the CPU transfer data itself, typically one word or one small buffer per interrupt.
How interrupt-driven I/O works step by step
An interrupt-driven transfer follows a fixed sequence of hardware and software steps. The driver writes a command to the device controller, then the calling thread is usually blocked so the scheduler can run another task. When the device completes the operation, its controller raises an interrupt request (IRQ) line or sends an equivalent message.
| Stage | Who acts | What happens |
|---|---|---|
| Command issue | Device driver | Writes registers to start the operation |
| Waiting | Scheduler | Blocks the requesting thread and runs other work |
| Interrupt raised | Device controller | Signals completion through the interrupt controller |
| Dispatch | CPU | Saves context and jumps via the interrupt vector table |
| Service routine | Interrupt service routine | Reads status, moves data, acknowledges the device |
| Completion | Kernel | Wakes the waiting thread and resumes normal execution |
The CPU checks for pending interrupts between instructions. When one arrives and is not masked, the processor saves the program counter and flags, switches to kernel mode and looks up the handler address in the interrupt vector table. After the handler returns, the interrupted program continues as if nothing had happened.
Top halves, bottom halves and deferred work
Modern kernels split interrupt handling into two parts to keep interrupts short. The top half, the interrupt service routine itself, runs immediately with some interrupts disabled and does only the urgent minimum: acknowledging the device and capturing data that would otherwise be lost.
The bottom half runs later with interrupts enabled and performs the slower processing, such as protocol handling or copying data to user buffers. Keeping the top half short reduces interrupt latency for every other device in the system.
| Kernel | Immediate part | Deferred mechanism |
|---|---|---|
| Linux | Hard IRQ handler | Softirqs, tasklets, workqueues, threaded IRQs |
| Windows | ISR at device IRQL | Deferred procedure call (DPC) |
| FreeBSD | Filter routine | Interrupt thread (ithread) |
| macOS | Primary interrupt handler | Interrupt event source on a work loop |
A frequent driver bug is doing too much in the top half, for example waiting on a lock or allocating memory that may sleep. Such code can stall the whole system or crash it, because the interrupt context cannot be suspended like a normal thread.
Interrupts compared with polling and DMA
Choosing between polling, interrupts and DMA is a trade-off between CPU efficiency and latency. Each interrupt costs a context save, a handler call and a cache disturbance, typically a few hundred nanoseconds to several microseconds depending on the platform. That overhead is negligible for a keyboard but significant for a device producing millions of events per second.
| Method | CPU involvement | Best suited to | Main drawback |
|---|---|---|---|
| Polling | Constant status checks | Very fast or very frequent events | Wastes cycles when idle |
| Interrupt-driven I/O | Only when the device signals | Slow or sporadic devices | Overhead per interrupt |
| Direct memory access | Setup and completion only | Bulk transfers such as disks | More complex hardware |
In practice, these methods are combined rather than exclusive. A network card uses DMA to move packets and an interrupt to announce completion, and the driver switches to polling under heavy load. Linux NAPI and interrupt coalescing in hardware both follow this hybrid pattern to prevent an interrupt storm known as receive livelock.
Delivery mechanisms and practical limits
Interrupts reach the CPU through an interrupt controller. Older PCs used the 8259 PIC with only 15 usable IRQ lines that devices often had to share. Current x86 systems use the APIC architecture, and PCI Express devices use message signaled interrupts (MSI and MSI-X), which write a small message to a special memory address instead of asserting a physical line.
- MSI-X allows up to 2,048 vectors per device, so a multi-queue NIC or NVMe drive can target one interrupt per CPU core.
- Interrupt affinity settings steer each vector to a chosen core to improve cache locality.
- Shared legacy lines force every handler on that line to check whether its own device interrupted.
- Interrupt storms from faulty hardware or drivers can consume an entire core and freeze input.
Real-time systems also care about interrupt latency, the delay between the device signal and the first handler instruction. Long sections with interrupts disabled raise that latency, which is why kernel developers minimize interrupt-disabled regions.
Virtualized systems add another layer. A hypervisor must route device interrupts to the correct guest, and features such as posted interrupts and the IOMMU interrupt remapping table let assigned devices deliver interrupts to a virtual machine with little hypervisor involvement. Without them, every guest interrupt causes a costly exit to the hypervisor, which can dominate I/O latency for fast storage and network devices.
Explained without jargon
Imagine waiting for a parcel. You could walk to the door every minute to check. That is tiring and wastes your day. Instead, you wait for the doorbell and do other things meanwhile.
Interrupt-driven I/O works the same way. The processor asks a device to do a job. Then it turns to other tasks. When the device is done, it rings the bell with an interrupt. The processor stops briefly, handles the result and goes back to its work.
A typical use case
A laboratory workstation reads measurements from an instrument over a serial port at 115,200 bit/s. Each byte arrives roughly every 87 microseconds, which is a long time for a modern CPU. Polling the port would keep one core busy waiting almost all the time.
The serial driver instead enables the receive interrupt of the UART with a 14-byte FIFO threshold. The controller raises an interrupt only when the buffer is nearly full or a short timeout passes. The top half copies the bytes into a kernel ring buffer, and the bottom half wakes the analysis program. CPU use for data capture drops to well under one percent, no samples are lost and the same workstation runs real-time plotting without stutter.