| 发表于:2007-03-16 00:54:534楼 得分:0 |
sect "spin locks " of chap9 in linux kernel development 2nd 自旋锁可以在中断处理程序中使用,不过在获得锁之前,首先禁止本地中断(在当前处理器上的中断请求)。。。参见: spin locks can be used in interrupt handlers, whereas semaphores cannot be used because they sleep. if a lock is used in an interrupt handler, you must also disable local interrupts (interrupt requests on the current processor) before obtaining the lock. otherwise, it is possible for an interrupt handler to interrupt kernel code while the lock is held and attempt to reacquire the lock. the interrupt handler spins, waiting for the lock to become available. the lock holder, however, does not run until the interrupt handler completes. this is an example of the double-acquire deadlock discussed in the previous chapter. note that you need to disable interrupts only on the current processor. if an interrupt occurs on a different processor, and it spins on the same lock, it does not prevent the lock holder (which is on a different processor) from eventually releasing the lock. 还有,中断处理程序运行的时候,相应的中断线在所有处理器上都被屏蔽,以防同一中断线接受另一个新的中断,但通常情况下,其他的所有中断都是打开的。。。。。。,参见: section “writing an interrupt handler”of chap6, reentrancy and interrupt handlers interrupt handlers in linux need not be reentrant. when a given interrupt handler is EXECuting, the corresponding interrupt line is masked out on all processors, preventing another interrupt on the same line from being received. normally all other interrupts are enabled, so other interrupts are serviced, but the current line is always disabled. consequently, the same interrupt handler is never invoked concurrently to service a nested interrupt. this greatly simplifies writing your interrupt handler. sect “interrupt context”of chap6, 永远牢记:中断处理程序打断了其他代码(甚至可能是打断了在其他中断线上的另一中断处理程序),参见: always keep in mind that your interrupt handler has interrupted other code (possibly even another interrupt handler on a different line!). | | |
|