Open In App

Difference between Interrupt and Exception

Last Updated : 06 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In computer systems, interrupts and exceptions are like signals that tell the CPU to pause what it’s doing and handle something important. They both temporarily stop a running program, but they are not the same. They come from different sources and are used for different reasons. Knowing the difference between them is important if you’re learning about operating systems, embedded systems, or how computers work inside.

During the normal execution of a program, certain events may occur that cause CPU to temporarily pause its current operations. These events are collectively known as exceptions. Among these, events initiated by external hardware such as a keyboard press or a timer are specifically classified as interrupts.

An interrupt is actually considered one of the four classes of exceptions in computer systems. The four classes are:

  1. Interrupt
  2. Trap
  3. Fault
  4. Abort

Interrupt

An interrupt is a signal sent to the processor by external hardware indicating that it needs immediate attention. Interrupts are asynchronous, meaning they can occur at any time, regardless of what the processor is currently doing. The CPU responds by pausing its current execution, saving the current state, and jumping to a special routine called the Interrupt Service Routine (ISR) to handle the event.

Common sources of interrupts

  1. Keyboard input
  2. Mouse movements or clicks
  3. Timer (clock) signals
  4. Disk I/O completion
  5. Network packet arrival

After servicing the interrupt, the processor resumes the previously running task from where it left off.

Exception

An exception is an event triggered by the CPU itself, caused by something unusual or erroneous happening during the execution of instructions. Exceptions are synchronous they occur precisely at the point when a specific instruction causes an error or needs special handling.

Common causes of exceptions

  1. Division by zero.
  2. Invalid or illegal instructions.
  3. Accessing memory that doesn’t belong to the process (segmentation fault).
  4. System calls from user programs.

When an exception occurs, the CPU invokes an exception handler that determines how to respond it may terminate the program, retry the instruction, or perform corrective measures.

What is Trap, Fault and Abort

  1. Trap : It is typically a type of synchronous interrupt caused by an exceptional condition (e.g., breakpoint, division by zero, invalid memory access).
  2. Fault : Fault exception is used in a client application to catch contractually specified SOAP faults. By the simple exception message, you can’t identify the reason of the exception, that’s why a Fault Exception is useful.
  3. Abort : It is a type of exception occurs when an instruction fetch causes an error.

Difference between Interrupt and Exception

The table below contains the difference between the interrupt and exception:

Feature Interrupt Exception
Definition Triggered by external hardware to get CPU attention. Triggered by internal conditions or errors during instruction execution.
Origin External (outside the CPU). Internal (inside the CPU).
Timing Asynchronous(It can occur at any time, unrelated to current instruction.) Synchronous(It occurs during the execution of a specific instruction.)
Purpose To handle real-time external events (e.g., input/output devices). To handle errors or special conditions in program execution.
Handling Routine Handled by Interrupt Service Routine (ISR). Handled by Exception Handler.
Examples Keyboard press, mouse click, printer request, timer signal. Divide by zero, illegal instruction, invalid memory access, system call.
Masking Can often be enabled or disabled by the operating system. Generally cannot be masked.
Control Interference Interrupts are considered normal events and do not disrupt the system’s logical correctness. Exceptions are usually abnormal events and may terminate or crash the program.
Effect on Other Events May disable other hardware interrupts while being processed. Does not generally disable other exceptions.
Instruction Flow May interrupt the program at any point. Occurs exactly at the instruction causing the exception.


Next Article

Similar Reads