What Is an Interrupt in Computing? How the CPU Pauses, Handles, and Resumes

On a quiet machine, the processor fields about 3,000 interrupts every second. Start a disk read and the count more than doubles to 6,400, with disk-completion signals jumping from 7 to 386 a second. Nothing about the machine changed except the work asked of it. An interrupt is the signal behind those numbers. A device, or the CPU’s own code, tells the processor to stop what it is doing, deal with something urgent, and pick up where it left off.

What an interrupt is?

An interrupt is a signal sent to the processor. It arrives from a device that needs attention, or from the CPU’s own code, and it arrives at no fixed moment. The processor finishes the instruction it is running, saves its working state, runs a short routine called an interrupt handler, and returns to the exact instruction it left. The routine has a second name. You will meet it everywhere: interrupt service routine, or ISR. That routine usually lives inside the device’s driver: how a device driver works, from the request journey to the signed package that loads it.

Does the CPU check for interrupts after every instruction? It samples the interrupt lines at instruction boundaries, so a signal that arrives in the middle of an instruction waits for the boundary. That wait is short. One instruction takes nanoseconds, and the handler starts as soon as the boundary passes.

The older way to watch a device is polling: the CPU asks the device, in a loop, whether it has data yet. Polling wastes time when nothing is ready, and it adds delay when the check interval grows wide. Interrupts flip the direction. The device speaks when it has something, and the CPU spends its time on real work until then. Wikipedia’s interrupt article dates the first use to the UNIVAC 1103A in 1953, with the DYSEAC following in 1954 as the first machine to use interrupts for input and output. Polling still wins in one case: events that arrive constantly and on schedule, where asking costs less than the fixed price of an interrupt.

A doorbell is the closest everyday match. You cook while the bell stays silent, and you answer it only when it rings. You mark your place, deal with the visitor, and return to the same step in the recipe. A polling cook would walk to the door every ten seconds to check for visitors, even when the street is empty.

Press a key and the keyboard raises an interrupt. The CPU reads the key without ever asking the keyboard first. The full path from the switch under the key to the letter on screen is how a keyboard works.

What happens between the signal and the return?

Five steps carry the CPU from its work to the handler and back, whatever raised the signal. The cycle it pauses is the fetch-decode-execute cycle, the loop a CPU runs for every instruction.

  1. The processor finishes the instruction in flight. A signal never cuts an instruction in half.
  2. It saves its working state. The program counter and the registers go aside, usually onto the stack, so the handler can use them freely.
  3. It reads the handler address from the vector table, using the interrupt number as the index.
  4. The handler runs. It acknowledges the device, moves the urgent data, and clears the signal.
  5. The saved state returns, and the interrupted program continues at the instruction it left. Only elapsed time has changed.
Five steps the CPU follows when an interrupt arrives: finish, save, look up, handle, return

That save and restore is the price of the mechanism. It costs a few instructions, and it disturbs the contents of the CPU cache the interrupted program had built up. A handler that runs long makes the price worse, so handlers stay short: they do the urgent part and leave the rest for later. The save and restore themselves run in machine code, the same low-level code assembly language describes.

The processor returns through a special return-from-interrupt instruction. It restores the saved flags as well as the program counter. The interrupted code runs as before, flags included.

Hardware interrupts, software interrupts, and exceptions

Three kinds share the mechanism, and the difference that matters is who raises the signal and whether the CPU can wait for a better moment.

TypeRaised byCan the CPU wait?Example
Hardware interruptA device, at any momentYes, when maskableKeypress, packet arrival, disk read done
Software interruptRunning code, on purposeNo, it is the next instructionSystem call with the INT instruction
FaultThe executing instruction, by failingNoDivide by zero, page fault
TrapThe executing instruction, on purposeNoBreakpoint, system call on some CPUs
AbortHardware or system tables, severeNo, and the program often cannot restartMachine-check error

A software interrupt is a deliberate instruction. A program runs INT on x86 to ask the operating system kernel for a service, such as reading a file, and the CPU treats the request like any other interrupt: it saves state, switches privilege level, and jumps to the kernel handler. That crossing is the system call, and it is the only way an ordinary program reaches the kernel.

Is a system call an interrupt? Yes. It is a software interrupt, raised on purpose, and the program waits for the handler to return with the result. The same mechanism carries faults, with one difference: a fault is raised by an instruction that failed, so the program never asked for it.

The return address tells the kinds apart. A fault returns to the instruction that failed, so the CPU can try it again once the handler fixes the cause. A trap returns to the instruction after the trapping one, because the trapping instruction already did its job. An abort has no useful return address, which is why the program behind it usually cannot restart. ARM chips simplify the words and call every kind an exception, while RISC-V uses interrupt as the umbrella term and calls the internal ones exceptions.

Counting real interrupts

Those numbers come from a live count. No textbook supplied them. Linux exposes every interrupt count in /proc/interrupts, one row per source and one column per CPU, so a ten-second window before and after a defined load shows exactly which interrupts the load created.

Window (10 seconds)Total interrupts per secondDisk completions per secondTimer ticks per CPU per second
Idle2,9777.4238
Disk load: repeated direct reads of a 200 MB file6,426385.8455
Bar chart of measured interrupts per second: 2977 idle versus 6426 under disk load, and disk completions 7.4 versus 385.8

Two ratios carry the result. Total interrupts rose 2.16 times under the disk load, while disk-completion interrupts rose 52 times, from 7.4 a second to 385.8. The timer tick explains the gap: even idle, each CPU takes about 238 timer interrupts a second, and a busy CPU takes about 455. Most interrupts on a quiet machine come from the clock ticking, while device work adds a smaller share. One ranking page puts the timer at roughly 250 ticks a second, and I would not quote that as a fixed number. The idle rate measured here sits at 238, and the loaded rate at 455, so the figure holds for a quiet machine and understates a busy one.

The measurement here ran under Python 3.12.3 on a four-CPU system running kernel 7.0.0-44-generic, reading /proc/interrupts across ten-second windows. One machine and one window per case produced these numbers, so rates vary by machine, and the ratios are the lesson here. A network load was planned as a third window, and it did not run: the download returned nothing, so the disk numbers stand alone and no network measurement is claimed.

I expected the network window to show the same jump for the network card, and its failure is the reason only two windows appear here. A claim needs a run behind it, and the network run produced none.

You can run the same check yourself on Linux. Open a terminal, read cat /proc/interrupts, wait ten seconds, and read it again. The LOC row is the local timer tick, and the disk rows carry the completions. Compare the two reads while a large file copies, and the disk rows will jump the same way.

On Windows, open Performance Monitor, add the Processor counter called Interrupts/sec, and watch the line climb as a large file copies. Each completed read is one interrupt, and the path from a file name to those reads is how a file system works.

IRQ lines, the vector table, and the modern controller

An interrupt request, IRQ, is the signal itself, before the CPU turns it into a handler call. The Linux kernel’s own documentation defines an IRQ number as a kernel identifier for a hardware interrupt source, and the number usually counts the input pins on the machine’s interrupt controllers.

On the classic PC, sixteen IRQ lines carried every device, and the assignments were fixed. The table below lists the lines that still matter, with what replaced the rest.

IRQClassic deviceToday
0System timerStill the timer tick
1PS/2 keyboardStill IRQ 1 on PS/2 keyboards; USB keyboards arrive through the USB controller instead
2Cascade to the second controllerHistorical; one controller now handles all lines
8Real-time clockStill the clock
13Math coprocessorHistorical; the coprocessor lives inside the CPU now
Diagram of the path an interrupt travels: device, IRQ line, controller, CPU, handler

Two controllers replaced the original pair. The Advanced Programmable Interrupt Controller, APIC, spread interrupts across CPUs, and message-signalled interrupts, MSI and MSI-X, replaced the physical line with a small memory write from the device. A device no longer needs its own wire. It writes a message, the controller turns the message into a vector number, and the CPU looks the handler up in the interrupt descriptor table, the IDT. The table holds 256 entries on x86, and the operating system fills it during boot. User programs cannot rewrite it; only the kernel can.

Vector numbers are written in hex: the page-fault handler sits at 0x0E, and the keyboard call at 0x21. Those two digits carry the same place-value idea that hexadecimal numbers use.

Masking, priority, and the interrupts that cannot wait

A handler that runs at the wrong moment can corrupt shared data, so the CPU lets code switch interrupts off for short stretches. The interrupt flag, IF on x86, gates the maskable lines, and a mask register holds one bit per line, so each line can be switched on or off by itself. Masking dates to the IBM 650 in 1954, the first machine to offer it. The mask register is a row of bits, one per interrupt line, and reading it as place values is binary code in its simplest working form.

Can the CPU just ignore an interrupt? A maskable one, yes, until the line is unmasked. The signal waits as pending, and the handler runs once the mask lifts. A non-maskable interrupt has no such option. It signals a memory error, a power failure, or a watchdog timeout, and the CPU answers it whatever else is running.

Masking is a tool with a cost. A critical section runs with interrupts off so no handler can touch its data halfway through, and every microsecond the mask stays up is a microsecond each device waits. Keep the section short, and the delay stays invisible. Keep it long, and keystrokes arrive late and packets wait in the buffer.

Priority sorts the queue when several signals arrive together. A higher-priority interrupt can interrupt a lower-priority handler, and the saved contexts pile up on the stack until each handler returns in turn. The TX-2 machine introduced priority levels in 1957. Level-triggered lines hold their signal high until the device is served, so several devices can share one line; edge-triggered lines fire once on the change and release the line. A wired-OR level line can fire with no source at all, a spurious interrupt, when the voltage settles too slowly after the device clears. A good handler checks every source on its line and does nothing when none of them is active.

The failure mode has a name: interrupt storm. Interrupts arrive faster than the handlers clear them, the CPU spends its time in handlers, and normal programs starve. The fixes are those tools in reverse: mask the noisy line, let the controller coalesce several events into one signal, or switch the device to polling while the flood lasts.

Where interrupts show up in everyday computing?

No device sends the most important interrupt. The timer fires hundreds of times a second on every running machine, and each tick hands the CPU to the operating system, which decides whether the running program has had its share. That decision is preemptive multitasking: no program can hold the processor by refusing to yield, because the timer takes it away on schedule.

Direct memory access extends the idea to moving data. The CPU tells the disk controller where the data goes and how long the transfer runs, then returns to other work. The controller moves the bytes itself and raises one interrupt when the transfer finishes. The processor neither waits for the data nor moves it; it starts the transfer and is notified at the end. Linux splits handler work the same way: the top half acknowledges the hardware and copies the data out, and the bottom half, a softirq or work queue, does the heavier processing after interrupts are switched back on.

Real-time systems live or die on the same numbers. An industrial controller, a cardiac monitor, and an audio interface all have deadlines measured in microseconds, and a missed deadline makes the output physically wrong: the robot arm overshoots, the audio buffer clicks. A general-purpose kernel can defer a handler for milliseconds under load, so those systems run a real-time kernel that bounds the delay. The bound is what they pay for; raw speed does not buy it.

Polling still earns its place where events arrive constantly and on schedule. A gaming mouse reports movement a thousand times a second, and asking on a fixed beat costs less than raising one for each report. The rate at which the mouse reports is the mouse polling rate, and the choice of rate is a trade between responsiveness and CPU time.

The numbers in the measurement section came from one machine, and yours will differ. Read /proc/interrupts on Linux, or open the Interrupts/sec counter in Performance Monitor on Windows. Note the totals, start a large file copy, and read them again. The disk rows will jump, the timer row will keep its beat, and the totals will roughly double. When they do, you are watching the mechanism at work: the machine does not ask its devices whether they need anything. It waits, and the devices speak first.

Frequently asked questions

Can two interrupts arrive at the same time?

Yes, and the controller sorts them by priority. The higher-priority signal gets its handler first, while the lower-priority one waits as pending. If the first handler is still running when the second arrives, the CPU saves that handler’s state too and runs the higher-priority one on top of it. The stack unwinds in reverse order when each handler returns.

Why does my mouse feel laggy when the CPU is busy?

A busy CPU takes longer to reach each handler. The mouse signal still arrives on time, but the handler that reads the new position queues behind whatever the CPU is doing, and a long queue turns into visible lag. The same delay hits keystrokes and audio first, because those are the inputs people notice within milliseconds.

Do interrupts slow down a computer?

They cost something, and the cost is measurable. Each interrupt saves and restores CPU state, and the live count shows a disk load doubling the total interrupt rate from about 3,000 to about 6,400 a second. On a modern multi-core machine that overhead stays small beside the work itself. The cost only turns into a problem when one device fires far more often than its handler can clear, which is the interrupt storm case.

How many interrupts can a CPU handle?

There is no fixed number. The limit comes from handler length and CPU speed: a handler that takes a microsecond caps the rate near a million a second, while a handler that takes a hundred microseconds caps it near ten thousand. The live count here reached about 6,400 a second under a light disk load with room to spare. Servers that move network traffic measure their rates in the hundreds of thousands per second per core.

Are interrupts used in phones and embedded devices?

They are used more there than on desktops. A microcontroller in a sensor or a remote control sleeps with almost no power draw until an interrupt wakes it, so the battery lasts months instead of days. The same idea runs the anti-lock brakes in a car and the pacemaker timers in medicine, where the interrupt carries a hard deadline instead of a convenience.

user profile reference
Kaleem
Computer, AI and Web Technology Specialist | Web | + posts

Kaleem is a Computer Science graduate (Virtual University of Pakistan) and the founder and editor of Valley AI, where he publishes in-depth, tested guides on computer hardware, artificial intelligence, and how the internet works. Every guide is researched from primary sources, tested hands-on where possible, and updated when the facts change.

Leave a Comment