CPU interrupt code definition
A CPU interrupt code is a signal or instruction that tells the CPU (a computer’s central processing unit) to stop what it is doing and handle something important right away. Interrupts can come from hardware (like a keyboard or mouse) or software (like a program request) to help the CPU quickly deal with urgent tasks. Those urgent tasks may be reading input from the keyboard, moving the mouse pointer, or saving data from a failing hard drive.
See also: CPU contention
How a CPU interrupt code works
- 1.Interrupt happens. A device or program sends a signal (interrupt) to the CPU to get its attention. For example, you press a key on the keyboard.
- 2.CPU pauses work. The CPU stops what it is doing and saves its current progress so it can return to it later.
- 3.The code is checked. The CPU gets the interrupt code, which is like a label that tells it what kind of event just happened.
- 4.CPU finds the right response. The CPU uses the interrupt code to look up the correct instructions in a list called the interrupt vector table.
- 5.CPU runs the handler. The processing unit follows the instructions (interrupt handler) to deal with the event. For example, the interrupt handler processes the keypress and displays the letter on the screen.
- 6.Back to normal. Once the interrupt is handled, the CPU restores its progress and continues with its previous task.
Types of interrupts
- Hardware interrupts — Triggered by external devices (e.g., keyboard, mouse, disk drive) to signal the CPU for attention.
- Software interrupts — Initiated by software programs to request services from the operating system or to handle errors.
- Maskable interrupts — Can be disabled or ignored by the CPU if needed (e.g., non-urgent tasks).
- Non-maskable interrupts (NMI) — Critical interrupts that cannot be ignored by the CPU, often used for system errors or hardware failures.