5.5.14 · D3Embedded Systems & Real-Time Software

Worked examples — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

3,783 words17 min readBack to topic

The scenario matrix

Every case this topic can throw at you falls into one of these cells. Each worked example below is tagged with the cell it covers.

# Case class What varies Example
C1 Bounded inversion (baseline) H waits only for L's CS Ex 1
C2 Unbounded inversion (the bug) M sneaks in, no protocol Ex 2
C3 PIP fix — single lock boosting removes M Ex 3
C4 PIP limit — chained/nested locks blocking sums Ex 4
C5 PCP — nested locks, blocked once ceiling gate Ex 5
C6 Deadlock case: PIP allows it, PCP forbids two locks, opposite order Ex 6
C7 Degenerate: only 2 priority levels / no shared lock no inversion possible Ex 7
C8 Limiting value: CS length → 0 and M runtime → ∞ where the bound lives Ex 8
C9 Real-world word problem (Mars Pathfinder numbers) apply to a story Ex 9
C10 Exam twist: ICPP timing — blocked before it starts immediate ceiling Ex 10

We compute (blocking of H) in each cell. Every worked example that has geometry-in-time (a schedule on a clock) gets its own timeline figure, so you see the blocking, never just read a number.


Ex 1 — C1: Bounded inversion (the acceptable baseline)

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 2 — C2: Unbounded inversion (no protocol, the bug)

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 3 — C3: PIP fixes the single-lock case

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 4 — C4: PIP's limit — chained (nested) blocking sums up

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 5 — C5: PCP — nested locks, blocked at most once

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 6 — C6: The deadlock case — PIP allows it, PCP forbids it

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 7 — C7: Degenerate inputs — when inversion is impossible

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 8 — C8: Limiting values — where the bound really lives

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 9 — C9: Real-world word problem (Mars Pathfinder, with numbers)

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Ex 10 — C10: Exam twist — ICPP blocks you before you start

Figure — Priority inversion — problem and solutions (priority inheritance, priority ceiling)

Recall

Recall Test yourself on the matrix

Which cell? For each, name the answer.

  • Two tasks, one lock, no M — bounded or unbounded? ::: Bounded, (C1)
  • What single term makes Ex 2 unbounded? ::: M's runtime , unrelated to the lock (C2)
  • PIP on Ex 2: what is ? ::: ms — just L's critical section (C3)
  • Nested locks under PIP vs PCP: sum or max? ::: PIP sums the CSs; PCP takes the max (C4/C5)
  • Which protocol prevents deadlock? ::: PCP (acyclic ceiling ordering); PIP does not (C6)
  • Shrinking the critical section to near-zero — does it fix unbounded inversion? ::: No; the danger is the blocking window, not CS size (C8)
  • ICPP: when can a task be blocked? ::: Only before it starts running, never after (C10)

See also: Real-Time Scheduling — Rate Monotonic & EDF, RTOS task states and context switching, Worst-Case Execution Time (WCET) analysis.