gpt4 book ai didi

linux - 如果中断处理程序开始旋转会发生什么?

转载 作者:太空宇宙 更新时间:2023-11-04 09:52:30 25 4
gpt4 key购买 nike

我正在关注 Linux 设备驱动程序。当它引入自旋锁时,它给出了以下示例:

Your driver is executing and has just taken out a lock that controls access to its device. While the lock is held, the device issues an interrupt, which causes your interrupt handler to run. The interrupt handler, before accessing the device, must also obtain the lock. Taking out a spinlock in an interrupt handler is a legitimate thing to do; that is one of the reasons that spinlock operations do not sleep. But what happens if the interrupt routine executes in the same processor as the code that took out the lock originally? While the interrupt handler is spinning, the noninterrupt code will not be able to run to release the lock. That processor will spin forever.

我不明白为什么如果中断处理程序正在旋转,则无法执行非中断代码。

是不是中断处理程序中的routine不能被抢占?如果是这样,是不是说中断例程必须是原子的?

最佳答案

Is it because the routine in the interrupt handler cannot be preempted?

不是通过进程上下文代码。

If so, is that to say the interrupt routine must be atomic?

它可能被更高优先级的中断或 NMI(或 SMM)中断。

关于linux - 如果中断处理程序开始旋转会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9403694/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com