Why can't you sleep while holding spinlock?

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

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

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 12:31

    Apart from what willtate has mentioned, assume that a process sleeps while holding a spilock. If the new process that is scheduled tries to acquire the same spinlock, it starts spinning for the lock to be available. Since the new process keeps spinning, it is not possible to schedule the first process and thus the lock is never released making the second process to spin for ever and we have a deadlock.

提交回复
热议问题