- 論壇徽章:
- 0
|
enable_irq時,如果發(fā)現(xiàn)還有IRQ_PENDING,就說明存在丟失的中斷,需要挽救。
但關(guān)于IRQ_REPLAY,書中說是為了防止多次產(chǎn)生一個丟失的中斷。
我的問題是:
即使不使用IRQ_REPLAY,在什么情況下會多次產(chǎn)生一個丟失的中斷呢?
代碼中,spin_lock已經(jīng)保護了整段代碼,并且hw_resend_irq是LAPIC發(fā)出的,會立即在本處理器上產(chǎn)生,也就是說,
執(zhí)行到最后的spin_unlock(這里書中寫錯了,不是spin_lock)時,根本沒有機會再次進入這段代碼,那么怎么會產(chǎn)生“多次產(chǎn)生一個丟失的中斷”的情況呢?
ULK 原文如下:
spin_lock_irqsave(&(irq_desc[irq].lock), flags);
if (--irq_desc[irq].depth == 0) {
irq_desc[irq].status &= ~IRQ_DISABLED;
if (irq_desc[irq].status & (IRQ_PENDING | IRQ_REPLAY))
== IRQ_PENDING) {
irq_desc[irq].status |= IRQ_REPLAY;
hw_resend_irq(irq_desc[irq].handler,irq);
}
irq_desc[irq].handler->enable(irq);
}
spin_lock_irqrestore(&(irq_desc[irq].lock), flags);
The function detects that an interrupt was lost by checking the value of the IRQ_PENDING flag. The flag is always cleared when leaving the interrupt handler; therefore, if the IRQ line is disabled and the flag is set, then an interrupt occurrence has been acknowledged but not yet serviced. In this case the hw_resend_irq( ) function raises a new interrupt. This is obtained by forcing the local APIC to generate a self-interrupt (see the later section "Interprocessor Interrupt Handling").
***The role of the IRQ_REPLAY flag is to ensure that exactly one self-interrupt is generated. ***
Remember that the _ _do_IRQ( ) function clears that flag when it starts handling the interrupt. |
|