首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

中止处理函数用spinlock注意点

2013-11-08 
中断处理函数用spinlock注意点参考:http://stackoverflow.com/questions/4752031/why-cant-you-sleep-whil

中断处理函数用spinlock注意点

参考:http://stackoverflow.com/questions/4752031/why-cant-you-sleep-while-holding-spinlock

 

当内核进程A拥有spinlock的时候,发生中断,且ISR也想拥有spinlock,所以ISR会一直自旋下去。

所以,加入一定要在ISR中使用spinlock的话,记得使用在内核进程中获取spinlock之前diasble interrupt.

 

Example: 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 re;ease the lock. That processor will spin forever.

 

热点排行