Interrupts
Interrupts
An interrupt occurs when an event needs attention while a computer is running. The machine automatically pauses the running program and transfers control to a program that handles the event. After handling it, execution normally returns to the paused program.
Interrupt sources include mouse movement, mouse clicks, keyboard input, and a printer requesting service or reporting completion.
Modern computers use interrupt systems mainly to:
-
Improve computer-system efficiency: processors work much faster than peripherals, and interrupts coordinate their operation. When a peripheral needs to exchange information with the processor, it sends an interrupt request, which the processor handles promptly.
-
Maintain reliable operation: applications cannot perform privileged operations directly and must request them through system calls. Out-of-bounds memory access could disrupt a program or corrupt another program's information. Memory-management hardware detects such access and raises an exception so the processor can take protective action.
-
Meet real-time requirements: monitoring and control devices send interrupt requests, and the processor responds and handles them within the system's real-time constraints.
-
Support fault handling: fault-detection and diagnostic components raise interrupts or exceptions when they detect a fault or error, allowing the system to record and isolate the fault as a basis for further handling.
A device interrupt: pause, handle, resume
Program progress
- 1Run program
- 2Pause program
- 3Handle event
- 4Resume program
KNOWLEDGE QUIZ
What happens when you press a key?
A drawing program is running when the user presses the A key.
- Put these actions in order: handle the keyboard event, continue the drawing program, pause the drawing program.
- After handling the event, does the drawing program restart or continue from where it paused?
- Name one other device event that can generate an interrupt.