Interrupts can happen often over the course of a program execution. They are not always due to system failures and may be added in consciously by the programmer as a benchmark or other form of check. In essence, an interrupt is a signal sent to a processor from either hardware or software that tells the processors that there is an event occurring which requires its urgent attention. In response, the processor will stop executing the instructions in its current thread of activity, save that state so it may return to it after, and begin running an interrupt handler program designed to deal with such events.
There are two main kinds of interrupts that can be signalled:
- Hardware interrupts
Hardware interrupts are signals that originate from an external device to the processor such as a disk controller, mouse, etc. An easy example of a hardware interrupt is pressing a keyboard key. This sends a signal to the processor that it has received user input to consider, even if the program is written in a way that pressing a key will do nothing. Hardware interrupts like that are synchronous, meaning they can occur in the midst of instruction execution. Initiating a hardware interrupt is called an interrupt request.
- Software interrupts
Software interrupts are originated by an exceptional condition in the processor itself (known as a trap or exception) or a certain instruction fed into it that triggers an interrupt when executed. The former is frequently used by programmers to handle errors and and special events within their program that could be triggered during its execution. These kinds of interrupts work much like function calls; they point to a new set of instructions to carry out before normal activity can be resumed. A common example use of such an interrupt is a request for service from a device driver or other low-level system software device.© BrainMass Inc. brainmass.com December 16, 2018, 2:36 pm ad1c9bdddf