Reputation: 797
Suppose that a Linux driver code acquires a spinlock, inside the critical section a function call force the process running on top of the driver to sleep. Knowing that to hold spinlock disables preemption on the relevant processor, is it possible for the process to wake up, and consequently to permit the driver code to release the spinlock ?
Upvotes: 0
Views: 356
Reputation: 1918
while spinlock other process can't do anything to wake it up, you could try to use semaphores for this type of switching
Upvotes: 0
Reputation: 239371
No, it is not allowed to sleep while holding a spinlock. Code that does this is buggy.
The only way the process could be woken is if code running on another core did something to wake it up (which means that yes, it will certainly deadlock if there is only one core).
Upvotes: 1