Operating Systems and Embedded Software · Kernel
InterruptIRQ
Interrupt Request
Also known as hardware interrupt, ISR, interrupt service routine
A hardware or software signal that makes the processor suspend its current work and run a handler, so the system can react promptly to events such as a received CAN frame, a timer expiry or a completed DMA transfer.
Explanation
Interrupts let peripherals request attention without the CPU having to poll them. An interrupt controller collects the lines from peripherals, applies masking and priorities and signals the CPU, which saves its context and jumps to a handler. Lines may be level-triggered or edge-triggered, which determines how they are acknowledged.
Linux hides controller differences behind its generic IRQ layer, which separates flow handling (level, edge, fasteoi and per-CPU) from chip-specific operations such as mask, unmask and end-of-interrupt. Drivers register handlers with request_irq() or request_threaded_irq(). In the threaded form, a short primary handler runs in hard-interrupt context and the main work runs later in a kernel thread.
Interrupt handling directly affects latency: long handlers or long interrupt-disabled sections delay everything else. PREEMPT_RT forces most handlers into threads so they become schedulable and can be prioritised against application tasks. RTOS designs similarly keep ISRs short and hand work over to tasks.
How it works
A peripheral asserts its interrupt line. The controller latches it, checks masking and priority, and signals a CPU. The CPU saves state and enters the kernel's low-level entry code, which identifies the interrupt number and invokes the flow handler. The flow handler acknowledges or masks the line, runs the registered driver handlers and issues end-of-interrupt. Any deferred work then runs in thread context.
Automotive applications
- Receive and transmit-complete events from CAN and Ethernet controllers
- Periodic timer ticks driving control loops
- Watchdog pre-timeout warnings
- DMA completion for camera frames
Example
A CAN controller raises an interrupt when a frame arrives. On a PREEMPT_RT kernel, the primary handler only wakes the driver's interrupt thread. That thread runs at a configured real-time priority, passes the frame up the network stack and wakes the waiting control application.
An illustrative example: any figures in it are worked numbers, not measurements.
References
- Linux generic IRQ handling (opens in a new tab)
“The generic interrupt handling layer is designed to provide a complete abstraction of interrupt handling for device drivers.”
- Real-time preemption: Theory of operation (opens in a new tab)
Definitions are original summaries. Standards text is not reproduced; follow the links for the official publications.