An interrupt is a signal from a device attached to a computer or from a program within the computer that causes the main program that operates the computer (the operating system ) to stop and figure out what to do next. Almost all personal (or larger) computers today are interrupt-driven – that is, they start down the list of computer instruction s in one program (perhaps an application such as a word processor) and keep running the instructions until either (A) they can't go any further or (B) an interrupt signal is sensed. After the interrupt signal is sensed, the computer either resumes running the program it was running or begins running another program. A signal informing a program that an event has occurred. When a program receives an interrupt signal, it takes a specified action (which can be to ignore the signal). Interrupt signals can cause a program to suspend itself temporarily to service the interrupt.
Interrupt signals can come from a variety of sources. For example, every keystroke generates an interrupt signal. Interrupts can also be generated by other devices, such as a printer, to indicate that some event has occurred. These are called hardware interrupts. Interrupt signals initiated by programs are called software interrupts. A software interrupt is also called a trap or an exception.
Example of Interrupt:
Ø Mouse moved.
Ø Disk drive at sector/track position(old days).
Ø Keyboard key pressed.
Ø Printer out of paper.
Ø Video card wants memory access.
Ø Modem sending or receiving.
Ø USB scanner has data.
An interrupt handler, also known as an interrupt service routine (ISR), is a callback subroutine in microcontroller firmware, operating system or device driver whose execution is triggered by the reception of an interrupt. Interrupt handlers have a multitude of functions, which vary based on the reason the interrupt was generated and the speed at which the interrupt handler completes its task.
An interrupt handler is a low-level counterpart of event handlers. These handlers are initiated by either hardware interrupts or interrupt instructions in software, and are used for servicing hardware devices and transitions between protected modes of operation such as system calls.
Interrupt handlers are the routines that are called when an interrupt is detected. Interrupt handlers are usually short sections of code that are designed to handle the immediate needs of the device and return control to the operating system or user program.
Steps of handling Interrupts:
Ø Disable further interrupts.
Ø Store current state of program.
Ø Execute appropriate interrupt handling routine.
Ø Restore state of program.
Ø Enable interrupts.
Ø Resume program execution.