In an x86 microprocessor, there is a flag register having a 'trap bit'--when set, it causes the microprocessor to trap to an exception handler after every instruction. Then there is an 'interrupt bit' which, when set, enables interrupts and redirects to ISR. What happens when both of them are set simultaneously and an interrupt is received?
2 Answers
2
votes
The Intel SDM, volume 3, section 6.9, lists the relative priorities of simultaneous exceptions and interrupts. For the case you have asked about, Debug Trap Exceptions are priority 4, and Maskable Hardware Interrupts are priority 6. Thus the debug trap will be serviced.
If the debug exception descriptor in the IDT is a trap gate, the pending interrupt will be serviced at the next instruction boundary. If the descriptor is an interrupt gate, the IF flag is cleared as part of exception processing, so the interrupt will remain pending until IF is set to 1.
In any case, the Trap Flag is cleared as part of interrupt or exception processing, so debug traps do not occur during the interrupt or exception handler.
IF
(the bit in EFLAGS) merely allows external interrupts (like keyboard or timer). Are you asking what happens when there actually is an interrupt pending, other than the trap bit? – Peter Cordes