Skip to content

Priority inversion

Category: Hazards · Status: stub · Lessons: chapter 03, When locks go wrong (planned)

One line: A high-priority task waits for a lock held by a low-priority task, which is itself preempted by medium-priority work, so the most important task effectively runs last.

How it connects

flowchart LR
  n_liveness_failure["Liveness failure"]
  n_mutex["Mutex"]
  n_priority_inversion["Priority inversion"]
  n_mutex -->|can cause| n_priority_inversion
  n_priority_inversion -->|is a| n_liveness_failure
  classDef center stroke-width:3px
  class n_priority_inversion center
  classDef outside stroke-dasharray: 4 3
  class n_liveness_failure,n_mutex outside

In each language

The operating system POSIX PTHREAD_PRIO_INHERIT: a thread holding such a mutex runs at the priority of the highest-priority thread it blocks; Linux builds this on priority-inheritance futexes ↗ and RT-mutexes ↗

Where to read more