简体   繁体   中英

Software traps vs Hardware Traps

Based on my understanding, the basic difference between traps and interrupts is that the traps are synchronous and generated by exceptions (div by zero etc) while the interrupts are asynchronous(Multiple devices could try to interrupt at the same time although who wins the race is the one who acquires the lock to the work queue first). There are two types of interrupts : hardware and software. The div by zero exception is detected by the hardware and therefore that serves as an example for hardware traps.

I have two questions here.

  1. Is my understanding about the schemes correct and are there any more differences?
  2. Is there a thing called software trap? If so, An example would be helpful!

The syscall instruction could be considered a software trap. It causes all the elements of trap/interrupt handling (context switch to an interrupt service routine which executes fully privileged) but is triggered under software control.

Interrupts are not completely asynchronous either, since masking and unmasking occurs synchronously. Thus although no two asynchronous event can occur at exactly the same time, multiple interrupts can be unmasked at exactly the same time, in which case interrupt priorities, not order of occurrence, control servicing order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM