欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

操作系统学习之中断-interrupt

程序员文章站 2022-03-06 22:45:52
...
中断(interrupt)分为硬件中断和软件中断
硬件中断又可分为内部中断和外部中断
80386把外部中断称为“中断”,而内部中断则称为异常(exception)
trap大概就是指硬件内部中断了,不知道这里理解的对不对
下面附上google上查到的资料
本文仅供个人参考记录,如有不对之处,还望指正,谢谢

An interrupt is generally initiated by an I/Odevice, and causes the CPU to stop what it's doing, save its context, jump to the appropriate interrupt service routine, complete it, restore the context, and continue execution. For example, a serial device may assert the interrupt line and then place an interrupt vector number on the data bus. The CPU uses this to get the serial device interrupt service routine, which it then executes as above.
A trap is usually initiated by the CPU hardware. When ever the trap condition occurs (on arithmetic overflow, for example), the CPU stops what it's doing, saves the context, jumps to the appropriate trap routine, completes it, restores the context, and continues execution. For example, if overflow traps are enabled, adding two very large integers would cause the overflow bit to be set AND the overflow trap service routine to be initiated.
 
Read more: http://wiki.answers.com/Q/What_is_key_difference_between_a_trap_and_interrupt#ixzz1ctyEvxFy
 
 
Exceptions and interrupts are unexpected events that disrupt the normal flow of instruction execution. An exception is an unexpected event from within the processor. An interrupt is an unexpected event from outside the processor. You are to implement exception and interrupt handling in your multicycle CPU design.