Unit content
Priority inversion and priority inheritance
Priority scheduling can behave unexpectedly when tasks share a locked resource.
Suppose a low-priority task holds a mutex needed by a high-priority task. The high-priority task blocks. If a medium-priority task that does not need the mutex keeps preempting the low-priority owner, the high-priority task is indirectly delayed by the medium-priority task. This is priority inversion.
A priority inheritance protocol temporarily raises the lock owner's effective priority to that of the highest-priority waiter. The owner can then run soon enough to finish the critical section and release the resource.
After the lock is released, the inherited priority is removed.
Priority inheritance bounds one important source of blocking, but it does not make arbitrary locking harmless. Long critical sections, nested locks and deadlock can still violate timing requirements.
Real-time synchronization therefore cares not only about mutual exclusion, but also about how resource ownership interacts with scheduler priorities.