computing function triggered by an interrupt
Wikipedia
en.wikipedia.org › wiki › Interrupt_handler
Interrupt handler - Wikipedia
May 2, 2026 - The front-half (or first level) ... the handler's logical operation (such as conveying the newly received data to an operating system data queue). ... macOS, Microsoft Windows, z/OS, DESQview and some other operating systems used in the past—interrupt handlers are ...
ScienceDirect
sciencedirect.com › topics › engineering › interrupt-handling
Interrupt Handling - an overview | ScienceDirect Topics
When signals are used as the OS abstraction for interrupts and the signal handling routine becomes analogous to an ISR, the OS manages the interrupt table, which contains the interrupt and information about its corresponding ISR, as well as provides a system call (subroutine) with parameters that that can be used by the programmer.
How do CPU/OS interrupts work?
The CPU has a dedicated area of memory called the interrupt (vector) table. There's one entry per interrupt type, and each entry points to a memory address. When an interrupt happens, the CPU immediately stops, looks up the address in the table, and jumps to it. From there, it's up to the interrupt handler to run, which is obviously software defined. OS interrupts, not hardware interrupts, can be done by loading a value into a CPU register as your interrupt type, then triggering a dedicated hardware interrupt, where the handler jumps again to the appropriate point in the OS vector table, handing control back to the OS to perform it's actions. Once the handler has finished running, it signals a return which causes previous execution to continue. Raw hardware interrupts are not a multithreaded ordeal themselves, but since actual behavior is completely software based, should the handler wish to use parallel capabilities, it can do so. OS interrupts are a little different in those regards, but usually function close to the same way, however you can have a case where only a single core is interrupted by the OS, for example, to signal that a disk transfer has completed. Edit 1: am not a cpu engineer, this is all stated to the best of my knowledge. Edit 2: drinking game: take a swig every time you read "interrupt" More on reddit.com
What happens when an Interrupt Service Routine gets interrupted?
It depends on the operating system / microcontroller that you are talking about, but generally speaking they are queued and executed in order, and they can cause problems if they arrive faster than they can be serviced over a long period of time. See Interrupt Storm . More on reddit.com
How does an interrupt actually work?
The CPU just executes your program instructions endlessly.. so it needs to be told to do something different. There is likely a interrupt controller that handles this communication with the CPU and also deals with configuration of interrupt vectors (such as turning on/off vectors, priority masking, multi-vector, etc.) for the programmer In it's most basic form, the CPU only has to receive a digital pulse that it needs to jump to an interrupt vector, and if the CPU supports multiple vectors, which vector that is. Then the CPU needs to know which program location it needs to jump to in order to serve that interrupt. There is no specific standard for this, as each architecture does this different, but a simple example would be an interrupt vector table. This is basically an array of addresses which is indexed by the IRQ vector number. The MCU vendor hardcodes (or hardwires more specifically) certain IRQ vector numbers to certain interrupts. The address is basically the location at which the IRQ vector function is stored at. Now there are far more specifics in how to actually enter/exit interrupts. Some MCUs require explicit return instructions from interrupts, as their CPU is doing extra tricks under the hood. E.g. MIPS and older ARM CPUs had something called a shadow register set: these are present to reduce interrupt latency. As an interrupt can happen anywhere in the program and looks a lot like an unpredictable function call, the function that is being called (the IRQ vector) needs to store registers from the main program temporarely. Upon exit it also needs to restore them. This costs instructions and time. A shadow register set basically does this in hardware within 1 cycle, but requires some parts of the register file to be duplicated. Not all modern MCUs have this anymore, because IRQ latency used to be quite atrocious and is fairly reasonable now. Also, modern MCUs are better equipped with peripherals that don't always need high interrupt rates or CPU intervention, so it's less big of a deal. If you want ultimate timing predictability though, you wouldn't use a CPU to begin with. But there is a lot more to it than this. I highly recommended reading Patterson and Hennessy's book. It's a great into in how computers (and therewith MCUs) work. Also there are vendor documentations for IRQ controllers and whatnot, but those usually have quite a high jargon density that's a bit dry to go through. But it could be worth a try. edit: thanks for gold! More on reddit.com
Is it possible to implement try/catch exception handling in a programming language that transpiles to C?
Yes, because Turing completeness. Yes, just use longjmp. That's the way it was done historically. Yes, check out the wild shenanigans that Chicken Scheme manages to compile down into C! Yes: The C++ community is currently having a discussion about alternatives to exceptions that come with less runtime overhead. See: Zero-overhead deterministic exceptions: Throwing values status_code and standard error object for Zero-overhead deterministic exceptions C++ exceptions and alternatives P0323R10: std::expected More on reddit.com
What is interrupt?
An interrupt is a signal or request that prompts the processor to temporarily halt its current operations and execute a specific task or service. It allows the CPU to respond to events or conditions that require immediate attention, such as input/output operations or hardware malfunctions. Interrupts ensure efficient system performance by enabling the processor to handle critical tasks without continuously polling for events.
lenovo.com
lenovo.com › home
Interrupts in OS Explained: Types, ISR, IVT, PIC & Examples | Lenovo ...
What is the role of the interrupt handler?
The interrupt handler, also known as the interrupt service routine (ISR), is a special function or routine that executes when an interrupt occurs. Its role is to process the interrupt by performing the necessary actions, such as reading input data or handling errors. Once the interrupt is serviced, the handler ensures the CPU resumes its previous task. The interrupt handler is critical for efficient and accurate interrupt management.
lenovo.com
lenovo.com › home
Interrupts in OS Explained: Types, ISR, IVT, PIC & Examples | Lenovo ...
Can interrupts be used in embedded systems?
Yes, interrupts are widely used in embedded systems to handle real-time events and improve system responsiveness. They enable the processor to respond to external signals, such as sensor inputs or communication requests, without constant polling. Interrupts are essential for managing time-critical tasks in embedded systems, ensuring efficient resource utilization and meeting real-time constraints.
lenovo.com
lenovo.com › home
Interrupts in OS Explained: Types, ISR, IVT, PIC & Examples | Lenovo ...
Videos
14:35
SoC 101 - Lecture 7c: Interrupt Handling - YouTube
18:26
Operating System Interrupts - YouTube
02:15
Interrupt Handling | 2.1c | OCR A-Level Computer Science - YouTube
04:56
What is an Interrupt?? | Interrupt Handling in OS - YouTube
24:24
Building an OS - 9 - Interrupt handling - YouTube
2/2: Interrupts in operating system | How interrupts works ...
TutorialsPoint
tutorialspoint.com › what-are-interrupts-and-how-interrupt-handling-is-done-in-modern-operating-systems
What are interrupts and how interrupt handling is done in modern operating systems?
December 1, 2021 - Moreover, for every interrupt handling to occur there is an Interrupt service routine (ISR) or interrupt handler. In several operating systems such as Linux.
Lenovo
lenovo.com › home
Interrupts in OS Explained: Types, ISR, IVT, PIC & Examples | Lenovo US
The key difference lies in their origin—hardware interrupts come from external devices, while software interrupts are initiated internally. The interrupt handler, also known as the interrupt service routine (ISR), is a special function or routine that executes when an interrupt occurs.
Scaler
scaler.com › home › topics › operating-system › interrupt handling
Interrupt Handling- Scaler Topics
October 15, 2023 - But if there is some un-serviced interrupt, then the CPU will pay attention to that interrupt. One thing to note here is that the state of the current program which was in execution is saved along with its corresponding register states. After saving the state of the current process, the control is then given to a program to handle the interrupt, and every program is known as Interrupt Handler.
JumpCloud
jumpcloud.com › home › it index › what is interrupt handling?
What is Interrupt Handling? - JumpCloud
July 14, 2025 - Interrupt handling is the process by which a computer’s Central Processing Unit (CPU) responds to an interrupt signal. An interrupt indicates an event that requires immediate attention from the operating system.
K-state
faculty.salina.k-state.edu › tim › ossg › Introduction › OSworking.html
1.7. Basics of How Operating Systems Work — Operating Systems Study Guide
Interrupts are signals sent to the CPU by external devices, normally I/O devices. They tell the CPU to stop its current activities and execute the appropriate part of the operating system. ... Hardware Interupts are generated by hardware devices to signal that they need some attention from the OS.
GeeksforGeeks
geeksforgeeks.org › interrupts
What is an Interrupt? - GeeksforGeeks
December 28, 2024 - The processor is in supervised mode only while executing OS routines. It switches to user mode before executing application programs. Interrupt priority schemes are used in microprocessors and microcontrollers to manage multiple interrupt requests (IRQs). These schemes ensure that more urgent tasks are processed before less important ones, making them essential for real-time systems and efficient interrupt handling...
TutorialsPoint
tutorialspoint.com › how-interrupt-is-handled-by-os-and-what-are-the-services-for-user-and-system
How interrupt is handled by OS and what are the services for user and system?
An interrupt is generally called as a signal, which is informing a program that a particular event has occurred. It causes a receiving program to stop and create a program to serve the interrupt. Example − When some process is running into the operating system and when you type a keystroke on the keyboard, then this keystroke will become an interrupt for the running process. Interrupts are mostly caused by devices attached to the computer. An interrupt is handled by one of the important routines of the operating system i.e.
Mohitmishra786
mohitmishra786.github.io › exploring-os › src › day-32-interrupt-handling.html
Day 32: The Art of Interrupt Handling - Exploring Operating Systems
Here’s a peek at what this looks like in x86 architecture (one of my favorite parts of low-level programming): ; Example of an IDT entry structure struc IDT_ENTRY .offset_low resw 1 ; Lower 16 bits of handler address .selector resw 1 ; Kernel segment selector .zero resb 1 ; Reserved .type_attr resb 1 ; Type and attributes .offset_high resw 1 ; Higher 16 bits of handler address endstruc · When an interrupt occurs, the CPU needs to save everything it was doing - and I mean everything.
Oracle
docs.oracle.com › cd › E19253-01 › 816-4854 › interrupt-15678 › index.html
Chapter 8 Interrupt Handlers
An interrupt tells the CPU that the device needs attention and that the CPU should stop any current activity and respond to the device. If the CPU is not performing a task that has higher priority than the priority of the interrupt, then the CPU suspends the current thread.
Reddit
reddit.com › r/askprogramming › how do cpu/os interrupts work?
r/AskProgramming on Reddit: How do CPU/OS interrupts work?
May 7, 2019 -
I think I understand the broad picture that on receiving an interrupt (signals on special pins etc?), the CPU halts its current execution and either handles the interrupt or forwards it to the OS. I'm guessing this is how external device firmware communicates events to an OS, like keyboard input, network packet receipt, etc.
Is my understanding correct? Does all this happen on "one thread", and if not, how did it work before SMT/multi-core CPUs? I'd also appreciate being given some more detail around this, thanks in advance!
Top answer 1 of 3
14
The CPU has a dedicated area of memory called the interrupt (vector) table. There's one entry per interrupt type, and each entry points to a memory address. When an interrupt happens, the CPU immediately stops, looks up the address in the table, and jumps to it. From there, it's up to the interrupt handler to run, which is obviously software defined. OS interrupts, not hardware interrupts, can be done by loading a value into a CPU register as your interrupt type, then triggering a dedicated hardware interrupt, where the handler jumps again to the appropriate point in the OS vector table, handing control back to the OS to perform it's actions. Once the handler has finished running, it signals a return which causes previous execution to continue. Raw hardware interrupts are not a multithreaded ordeal themselves, but since actual behavior is completely software based, should the handler wish to use parallel capabilities, it can do so. OS interrupts are a little different in those regards, but usually function close to the same way, however you can have a case where only a single core is interrupted by the OS, for example, to signal that a disk transfer has completed. Edit 1: am not a cpu engineer, this is all stated to the best of my knowledge. Edit 2: drinking game: take a swig every time you read "interrupt"
2 of 3
3
Hardware translates the signal from one peripheral into the triggering of one particular CPU interrupt. This mapping may be configurable to some extent during initialization. Somewhere in memory the CPU has a table which determines where execution starts for each interrupt. It could be a table of addresses or branch instructions, depending on the CPU. Most interrupts can be masked in some way, either via a general mask or a priority based masking. If the interrupt is currently masked, nothing happens, and things start happening when the interrupt is unmasked. Otherwise things start happening immediately. First of all the CPU needs to save some state on a stack, so what was executing before can continue afterwards. Usually the hardware only automatically saves some of the state, and the OS saves the rest. This code is probably in assembler, and then control is passed to higher level code, often in C. At this point the OS needs to decide how to respond to the interrupt. Multiple hardware devices may share one interrupt. In a simple embedded system, there might be code which reads some hardware registers and decides what interrupt handler to call. In a more complex OS, drivers register with the OS during initialization, and when an interrupt occurs, the OS calls every driver which told the OS it uses that that particular interrupt. If none handle it, the OS reports an error. During initialization the driver also needs to configure the hardware to enable its interrupt functionality. Once the driver gets the interrupt, it still probably needs to check what happened and determine what needs to be done, because hardware may use the same interrupt for multiple conditions. This may be in the form of a loop rather than a one time check, in case there are multiple events to handle. The driver may need to do something to clear the interrupts, preventing unwanted repeats and/or allowing interrupts to work again when new events happen. The driver talks to both the hardware and to the OS, for example, getting keystrokes from the hardware and telling the OS about key input events. What the driver tells the OS might later wake up a program which was waiting for a key press. When all the drivers are done, the OS needs to finish up. It may need to perform some general process to clear that particular CPU interrupt. It also must restore any CPU state it saved, which is probably again done using assembler code. Finally, it executes an instruction, often a special return from interrupt instruction, which resumes execution. In a pre-emptive multitasking system, execution may resume in a different process or thread from the one that was interrupted, for example continuing the program that was waiting for key input. This decision would be performed by the operating system's scheduler. There also is the issue of masking interrupts. Often, once the CPU starts executing an interrupt handler, it disables all other interrupts which can be disabled, or other interrupts at that and lower priorities. This gets re-enabled after the interrupt is handled, though it can get enabled earlier via code. Some critical sections of code which must not be interrupted disable interrupts and then return them to their previous state at the end of that section. One example is writing to the interrupt vector table, because you don't want execution going to a mix of the old and new addresses. Yet another issue is kernel vs. user mode and the transitions in between. I'm not going to go into that here. Another thing to consider is that often when CPU load is not 100%, interrupts happen when the CPU is idle and in a low power mode. CPUs nowadays have special instructions which tell them to go into low power mode and wait for an interrupt. This can also involve reducing clock speed and CPU power supply voltage, and in some systems the OS needs to handle that as well. Another thing to consider is that some interrupts require prompt handling. Input data might be accumulating in a hardware queue which can overflow, or sound output might get glitches if interrupts don't keep providing new data soon enough. So, in some cases one needs to consider what work is quick enough to be done in an interrupt handler, and what needs to be done in other ways, such as in its own regular thread.
TechTarget
techtarget.com › whatis › definition › interrupt
What is interrupt in computing?
An OS usually includes code called an interrupt handler to prioritize interrupts and save them in a queue if more than one is waiting to be handled.
Shiksha
shiksha.com › home › it & software › it & software articles › operating systems articles › interrupts in operating system
Interrupts in Operating System - Shiksha Online
August 23, 2023 - Machine malfunctions cause these interrupts. When an interrupt occurs, the hardware saves relevant information about the interrupt routine and, if possible, disables the processor for more interrupts of the same type. The hardware then passes control to the appropriate interrupt handler routine.
OSDev Wiki
wiki.osdev.org › Interrupts
X86 Interrupts - OSDev Wiki
When an interrupt comes in, the IDT (which is setup by the OS in advance) is used to jump to code portion of the OS, which handles the interrupt (and therefore called the "interrupt handler" or "Interrupt Service Routines"). Usually the code interacts with the device, then returns to whatever ...
The IoT Academy
theiotacademy.co › home › interrupt handling in embedded systems – types of interrupt
Interrupt Handling in Embedded Systems - Types of Interrupt
August 23, 2025 - Usage: Handle real-time events (e.g., reading sensor data, time-critical tasks). Triggered intentionally by software via specific instructions (e.g., SWI in ARM, INT in x86). ... System calls (e.g., OS tasks). Debugging breakpoints. Usage: Facilitate controlled transitions to kernel mode or service routines. Hardware and software interrupts may sound similar, but differ in their source and trigger.