Subject: Re: interrupt masking
To: None <bill@twwells.com>
From: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
List: port-i386
Date: 09/18/1994 16:06:07
   If I understand this, the effect of masking the interrupt is to prevent it
   from re-occuring while the handler is active.

Basically.

   However, the cpl&ipending test
   does the same thing.

No, it doesn't.  If the interrupt were simply recorded in ipending,
then you could get excessive extra interrupts due to race conditions.
(e.g.  Ethernet driver reads last packet.  Before it's done processing
it, another one arrives, which triggers an interrupt.  It gets back to
the top of its loop and notices a new packet, and reads it.  There's
no need for another interrupt.)  One could even envision a rogue
device causing an infinite loop.

Whether or not this is a performance penalty in practice is another
question.

   (Actually, if I'm reading the code right, the ipending
   bits aren't ever set because of an interrupt on the same channel;

This is true iff the interrupt is masked in the ICU.

   Consider an interrupt just after the unmask and before the cpl is restored.
   That will cause a pending bit to be set, which will cause doreti to go to the
   resume point and then execute the handler with the interrupts unmasked.

Hm.  That sounds plausible.  If so, the unmasking should be done in
doreti on the final exit, it seems.  This would also prevent
starvation.

   As near as I can tell, the *only* time masking should matter is for an
   interrupt handler that actually fiddles with the ICU, as otherwise the
   difference between an interrupt masked by ipending and one masked in the ICU
   is invisible.

See above.  An interrupt masked only by ipending can get extra
interrupts, since it has no way of telling the the IRR line went low
again.


I could be convinced to switch the way this is done, except that I
don't agree with the way you're doing the fast interrupt handling.
The XintrN routines are specifically for dealing with hardware
interrupts; software interrupts should go through a different
mechanism.