The inversion problem
In a priority scheduler, a high priority thread should run before low priority ones. But if a low priority thread holds a lock the high priority thread needs, the high priority thread must wait. Worse, a medium priority thread can preempt the low holder, delaying it further. This is priority inversion, and it can stall the urgent thread indefinitely.
How inheritance fixes it
The priority inheritance protocol raises the holder temporarily.
- When a high priority thread blocks on a lock, the holder inherits the high priority.
- The boosted holder now cannot be preempted by medium threads, so it finishes the critical section quickly.
- On releasing the lock, the holder drops back to its original priority.
The boost lasts only as long as the holder owns the contended lock, and it propagates along chains of locks if needed.
Key idea
Priority inheritance temporarily lifts a lock holder to the priority of the highest thread waiting on it, so medium threads cannot preempt the holder and the urgent thread gets the lock without unbounded inversion.