Why can't you sleep while holding spinlock?

前端 未结 8 2002
醉梦人生
醉梦人生 2020-12-08 12:17

In the linux kernel, why can\'t you sleep while holding a spinlock?

8条回答
  •  萌比男神i
    2020-12-08 12:29

    I think this mail has a clarity answer:

    A process cannot be preempted nor sleep while holding a spinlock due spinlocks behavior. If a process grabs a spinlock and goes to sleep before releasing it. A second process (or an interrupt handler) that to grab the spinlock will busy wait. On an uniprocessor machine the second process will lock the CPU not allowing the first process to wake up and release the spinlock so the second process can continue, it is basically a deadlock.

提交回复
热议问题