Complete Computer Knowledge Portal

Saturday, March 30, 2013

Difference Between Interrupt and Trap

Sr. No.
Interrupt
Trap
1
Interrupt is an electronic alerting signal sent to the processor from an external device, either a part of the computer itself such as a disk controller or an external peripheral.
Software Interrupt caused either by an exceptional condition (e.g. divide by zero or invalid memory access)in the processor itself, or a special instruction in the instruction set which causes an interrupt when it is executed is called Trap.
2
An interrupt transfers control to an interrupt handler inside the operating system; it changes the operating system mode to kernel mode. The interrupt handler is determined using an interrupt vector, which is an array in the operating system that maps interrupt numbers to interrupt
handler addresses. An interrupt handler should return the machine to its state before the interrupt, and in particular should change The mode back to user mode.
A trap transfers control to a trap handler in The operating system and changes the mode to kernel mode. The trap handler is determined using a trap vector, which is an array in the operating system that maps trap Numbers to trap handler addresses. Traps are like exceptions in high-level languages
3
An interrupt can be used to signal the completion of an I/O to obviate the need for device polling.
A trap can be used to call operating system routines Or to catch arithmetic errors.
4
These are Asynchronous interrupt and may arrive at the execution of any instruction.
These are synchronous interrupt and arrives after the execution of any instruction.

No comments:

Post a Comment