linux为什么要禁止内核抢占,为什么linux在内核代码持有自旋锁后禁用内核抢占?...
我是
Linux的新手,正在閱讀Rubini& amp;的Linux設(shè)備驅(qū)動程序.科比特.我對一個與自旋鎖相關(guān)的陳述感到困惑;這本書說明
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.
問題:在單處理器系統(tǒng)上,如果內(nèi)核代碼(代表用戶進程執(zhí)行)持有自旋鎖,則禁用內(nèi)核搶占,那么另一個進程怎么能有機會運行并因此嘗試獲取自旋鎖?為什么Linux內(nèi)核會在內(nèi)核代碼持有自旋鎖時禁用內(nèi)核搶占?
總結(jié)
以上是生活随笔為你收集整理的linux为什么要禁止内核抢占,为什么linux在内核代码持有自旋锁后禁用内核抢占?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自动清理mysql的lock进程的脚本_
- 下一篇: linux内核功能关闭透明大页 功能,r