Page 1 of 1

Definition of masking and unmasking an irq

Posted: Sat Aug 23, 2003 4:57 pm
by beyondsociety
I've heard that you have to mask the irqs before enabling interrupts and unmask them after. What I would like to know is: what does masking and unmasking an irq or interrupt mean?

Re:Definition of masking and unmasking an irq

Posted: Sat Aug 23, 2003 5:19 pm
by Curufir
If an IRQ is masked then it can't create an interrupt based on the IRQ event.

Eg If I mask the timer IRQ then my timer ISR will never run (Unless I call it in software) even if I have interrupts enabled, because the PIC will never generate an interrupt when it receives the IRQ.

You aren't required to mask off the IRQs before remapping the PICs, simple turning off interrupts will do the trick as well. However it is worthwhile masking off all IRQs until such time as you have your IDT and ISR routines setup. Otherwise there's a tendency to turn interrupts back on and immediately triple fault when the timer IRQ goes off. Simple bug, but one that's not obvious to trace back if you aren't looking for it.

Personally I turn off interrupts, remap the PICs, then immediately mask off all IRQs and I haven't had any problems so far (Well not problems related to IRQs anyhow ;D).

You can't mask off interrupts themselves, but by careful setup with regard to privilege levels you can prevent the use of privileged interrupts by userspace applications.