You are on page 1of 1

Weekly 2 Assessment Questions

Outline the differences between an interrupt and a trap


The main difference between trap and interrupt is that trap is triggered by a user program to
invoke OS functionality while interrupt is triggered by a hardware device to allow the processor
to execute the corresponding interrupt handler routine. An operating system is event-driven.
The main difference between trap and interrupt is that trap is triggered by a user program to
invoke OS functionality while interrupt is triggered by a hardware device to allow the processor
to execute the corresponding interrupt handler routine.
An operating system is event-driven. An event can occur suddenly while executing a program. It
will trigger the operating system to execute. This will change the user mode into kernel mode.
After the execution of the OS, the control is passed back to the original program.  Traps and
interrupts are two types of events. A trap is raised by a user program whereas an interrupt is
raised by a hardware device such as keyboard, timer, etc. A trap passes the control to the trap
handler and the interrupt passes the control to an interrupt handler. After executing the handler,
the control switches back to the original program.

Difference Between Trap and Interrupt


 The trap is a signal raised from a user program that indicates the operating system to
perform on some functionality immediately while interrupt is a signal to the processor
emitted by hardware indicating an event that needs immediate attention.

 Method of Generating: A trap is generated by an instruction in the user program while an


interrupt is generated by hardware devices.

 Main Functionality: Further, a trap invokes OS functionality. It transfers the control to


the trap handler. An interrupt triggers the processor to execute the corresponding
interrupt handler routine.

 Occurrence: Also, a trap is synchronous and can arrive after the execution of any
instruction while an interrupt is asynchronous and can occur at the execution of any
instruction.

 Synonyms: A trap is also called a software interrupt while an interrupt is also called a
hardware interrupt.

Conclusion
Trap and Interrupt are two types of events. The difference between trap and interrupt is that the
trap is triggered by a user program to invoke OS functionality while the interrupt is triggered by
a hardware device to allow the processor to execute the corresponding interrupt handler routine.

You might also like