Interrupt vs. Trap

Difference Between Interrupt and Trap There are certain events during the use of a computer which cause the…

Difference Between Interrupt and Trap

There are certain events during the use of a computer which cause the CPU to come to a halt temporarily. These events are called interrupts. They are due to faults in hardware or software of the computer. If the halts are caused by the hardware, it will be called interrupt. On the other hand if the halt is caused by software, it will be called Trap or exception. In exception, the software generates automatic interruption.  Trap is an interruption caused by the programmer. In case of interrupt the control is given to the special subordinate termed as Interrupt Service Routine or ISR.


The word ‘interrupt’ is generally associated with hardware. The interrupt is caused by some external hardware events. Interrupts come from different sources like peripheral devices including mouse and keyboard, serial ports and parallel ports etc, disk drives, expansion cards like audio and video cards. Interrupt is not caused by any program related event. For example a key is pressed on the keyboard by the user, the interrupt sends the information that certain device needs attention. At an interrupt, the CPU will stop working its normal function. It will return to its normal function after correcting the interrupt. When CPU starts the ISR at the time of hardware interrupts, other interrupts are disabled. Interrupt flags have to be cleared if the user wants other interrupts to occur at the time of the running of ISR.


A Trap is a transfer of control initiated by the programmer. Trap and Exception are used interchangeably. Exception is an automatically occurring software interrupt. Some users suppose that a trap is a special subroutine call. That is why they are categorized as software invoked interrupts. The control in case of trap is transferred to the subordinate associated with the trap as a trap is always unconditional. The instruction invoking the routine for handling the trap is identified easily as an interruption is specified by an explicit instruction.

Difference between Interrupt and Trap

The major difference between the two is that interrupts are caused by hardware while traps are interrupts caused by software. Other hardware interrupts get disabled in hardware interrupt. But it is not so in case of traps. A user has to clear the interrupt flag if he wants to disallow hardware interrupts till a trap is served. The interrupt flag affects hardware. Clearing the flag does not prevent traps. The interrupts should restore the previous state of the CPU.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

i.e vs e.g

Difference between i.e and e.g We commonly encounter these two abbreviations daily in our creative writings in English.…

Vulva vs. Labia

Difference Between Vulva and Labia The vulva is the external genital organ of a female. Labia refers to…

Resort vs. Hotel

Difference between Hotels and Resorts Hotels It is true that the main agenda of hotels and resorts is…