What is the difference between Trap and Interrupt?

后端 未结 10 1068
时光说笑
时光说笑 2020-12-02 03:44

What is the difference between Trap and Interrupt?

If the terminology is different for different systems, then what do they mean on x86?

10条回答
  •  北海茫月
    2020-12-02 04:02

    A Trap can be identified as a transfer of control, which is initiated by the programmer. The term Trap is used interchangeably with the term Exception (which is an automatically occurring software interrupt). But some may argue that a trap is simply a special subroutine call. So they fall in to the category of software-invoked interrupts. For example, in 80×86 machines, a programmer can use the int instruction to initiate a trap. Because a trap is always unconditional the control will always be transferred to the subroutine associated with the trap. The exact instruction, which invokes the routine for handling the trap is easily identified because an explicit instruction is used to specify a trap.

提交回复
热议问题