what is meant by disabling interrupts?

trohit picture trohit · Aug 6, 2010 · Viewed 19.1k times · Source

When entering an inteerupt handler, we first "disable interrupts" on that cpu(using something like the cli instruction on x86). During the time that interrupts are disabled, assume say the user pressed the letter 'a' on the keyboard that would usually cause an interrupt. But since interrupts are disabled, does that mean that:

  1. the interrupt handler for 'a' would never be invoked, since interrupts are disabled in the critical section or
  2. the interrupt will be handled by the os but delayed, until interrupts are enabled again. Specifically, will the user need to press 'a' again, if the first time he pressed 'a' was at a time when interrupts were disabled ?

Answer

S.Lott picture S.Lott · Aug 6, 2010

Often, one interrupt is "queued" by hardware.

[An interrupt is often just a logic gate that can stick on; once it's on, it stays on for a while.]

If the user hit 'a' once only during the interval when interrupts were disabled, it would register as an interrupt when they were re-enabled.

If the user somehow managed to hit 'a' twice during the interval when interrupts were disabled, one would register as an interrupt when they where enabled. Whether it was the first or the second depends on the exact logic gate configuration.