October 2017
Intermediate to advanced
354 pages
9h 28m
English
Spinlocks by design are better suited for scenarios where lock is held for short, fixed intervals of time, since busy-waiting for an indefinite duration would have a dire impact on performance of the system. However, there are ample situations where a lock is held for longer, non-deterministic durations; sleeping locks are precisely designed to be engaged for such situations. Kernel mutexes are an implementation of sleeping locks: when a caller task attempts to acquire a mutex that is unavailable (already owned by another context), it is put into sleep and moved out into a wait queue, forcing a context switch allowing the CPU to run other productive tasks. When the mutex becomes available, the task in the wait queue is woken up ...