Skip to main content

Interrupt

In Turkish
kesme
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/interrupt

In short

An interrupt is a signal to the CPU that an event needs immediate attention, making it pause its current work and run a special handler in the kernel.

What is an interrupt in computing?

An interrupt is how hardware devices and software tell the CPU that something has happened: a key was pressed, a network packet arrived, a disk finished reading, or a timer ran out. Without interrupts, the CPU would have to keep checking every device to see whether it needed anything, which wastes time and power.

When an interrupt arrives, the CPU finishes its current instruction, saves the state of what it was doing, switches to kernel mode, and looks up the matching handler in an interrupt table set up by the kernel. The handler, called an interrupt service routine, deals with the event, and then the CPU restores the saved state and resumes where it left off. Handlers must be very quick, so kernels usually split the work: a short first part acknowledges the device, and the rest is deferred to run a little later. Interrupts come from devices (hardware interrupts, or IRQs), from a timer that lets the scheduler preempt running tasks, and from the CPU itself when an instruction causes an exception such as a page fault or division by zero.

An interrupt works like a doorbell. You don't walk to the front door every minute to check for visitors; you keep cooking until the bell rings, answer it, and then return to the recipe. Interrupts are what make keyboards and mice feel instant, let the operating system share the CPU fairly, and let idle processors sleep until real work arrives.

Interrupts are often contrasted with polling, where software repeatedly checks a device instead of waiting to be notified; very fast network cards sometimes switch to polling under heavy load because handling millions of interrupts costs more than checking. An interrupt is also different from a Unix signal: interrupts are delivered to the CPU and handled by the kernel, while signals are notifications the kernel delivers to a user process. Exceptions in programming languages, handled with try and catch, are a separate, language-level mechanism.

Key takeaways

  • An interrupt makes the CPU pause its current work to handle an urgent event.
  • The kernel runs a matching interrupt handler and then resumes the interrupted work.
  • Hardware devices, timers, and CPU exceptions can all raise interrupts.
  • Timer interrupts make preemptive CPU scheduling possible.
  • Interrupts avoid the waste of constantly polling devices.

Example

Watching interrupts on Linuxbash
# How many interrupts each CPU core has handled, per device
head -n 10 /proc/interrupts

# Interrupts ("in") and context switches ("cs") per second, 5 samples
vmstat 1 5

Readers ask

What is the difference between an interrupt and polling?

With polling, the CPU repeatedly asks a device whether it needs attention. With interrupts, the device notifies the CPU only when something happens, which usually saves time and power.

What is an IRQ?

IRQ stands for interrupt request, the signal a hardware device sends to request the CPU's attention. Each device or device queue is assigned an IRQ number so the kernel knows which handler to run.

What is an interrupt handler?

An interrupt handler, or interrupt service routine, is the kernel or driver code that runs in response to a specific interrupt. It must finish quickly, so longer work is usually deferred to run afterward.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings