What is Interrupt Handling?
Interrupt handling, told as a story about a mechanic who jots down their place and runs to an urgent bell.
An urgent car suddenly honks while the mechanic is working.The mechanic must decide: keep working, or stop and look.
A mechanic glancing over again and again for an urgent car wastes working time.We need the urgent car to signal in directly.
When the bell rings, jot down your place and run to it.Once the urgent job is done, pick back up exactly where you left off.
Handling an interrupt takes these five steps, ① to ⑤.The same bell type always reaches the same handler.
Unlike the network-card bell story, this page covers the sequence common to every bell.Every bell follows the same sequence — save, handle, resume.
Interrupt handling is the sequence of jotting down your place when a signal fires, letting the right handler do the urgent job, then resuming exactly where you left off.
An interrupt is a signal that makes the CPU pause its current instruction stream to handle something urgent. The sequence is: ① interrupt occurs ② current registers and program counter are pushed to the stack ③ the interrupt vector table is consulted for the matching ISR (interrupt service routine) address ④ the ISR runs ⑤ the saved state is restored and execution resumes where it left off. This saves CPU resources compared to constantly polling for status.
When grown-ups say it
- Interrupt
- The bell an urgent car honks. A signal that pauses current work.
- Save/Restore State
- Jotting down your place, then reading it back later. Registers and the program counter go onto the stack.
- Interrupt Vector Table
- A nameplate board mapping each bell type to its handler. Holds the handler address for each interrupt type.
- ISR (Interrupt Service Routine)
- The one who actually runs to the bell and handles it. The handler code the vector table points to.
- Polling
- Constantly glancing over to check. Can be less efficient than interrupts.
- Interrupt Priority
- Handling the more urgent bell first. Matters when several bells ring at once.
- Software Interrupt
- The mechanic pressing the bell themselves to make a request. Older x86 system calls used this; x86-64 has a dedicated syscall instruction.
- Network Interrupt
- The story about the network-card bell specifically. Covered in depth in another field (the networking field). → the bell that says a parcel just arrived