linux为什么要禁止内核抢占,为什么linux在内核代码持有自旋锁后禁用内核抢占?...
我是
Linux的新手,正在閱讀Rubini& amp;的Linux設備驅動程序.科比特.我對一個與自旋鎖相關的陳述感到困惑;這本書說明
If a nonpreemptive uniprocessor system ever went into a
spin on a lock, it would spin forever; no other thread would ever be able to obtain
the CPU to release the lock. For this reason, spinlock operations on uniprocessor systems
without preemption enabled are optimized to do nothing, with the exception of
the ones that change the IRQ masking status.
書還說明了這一點
The kernel preemption case is handled by the spinlock code itself. Any time kernel
code holds a spinlock, preemption is disabled on the relevant processor. Even uniprocessor
systems must disable preemption in this way to avoid race conditions.
問題:在單處理器系統上,如果內核代碼(代表用戶進程執行)持有自旋鎖,則禁用內核搶占,那么另一個進程怎么能有機會運行并因此嘗試獲取自旋鎖?為什么Linux內核會在內核代碼持有自旋鎖時禁用內核搶占?
總結
以上是生活随笔為你收集整理的linux为什么要禁止内核抢占,为什么linux在内核代码持有自旋锁后禁用内核抢占?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自动清理mysql的lock进程的脚本_
- 下一篇: linux 其他常用命令