Skip to content

Commit 800f6a0

Browse files
authored
Simplified priority inheritance explanation (#88)
Add explanation of mutex priority inheritance behavior along with important differences a user should be aware of.
1 parent 725d721 commit 800f6a0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ch08.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,9 @@ undesirable behavior would be exaggerated further if a medium priority
692692
task started to execute while the high priority task was waiting for the
693693
semaphore—the result would be a high priority task waiting for a low
694694
priority task—without the low priority task even being able to execute.
695+
This is most often referred to as _unbounded priority inversion_ because
696+
the medium priority task could block the low and high priority tasks
697+
indefinitely.
695698
This worst case scenario is shown in Figure 8.4.
696699
697700
@@ -737,6 +740,22 @@ As just seen, priority inheritance functionality effects the priority of
737740
tasks that are using the mutex. For that reason, mutexes must not be
738741
used from interrupt service routines.
739742
743+
FreeRTOS implements a basic priority inheritance mechanism which was
744+
designed with optimizing both space and execution cycles in mind. A full
745+
priority inheritance mechanism requires significantly more data and
746+
processor cycles to determine inherited priority at any moment,
747+
especially when a task holds more than one mutex at a time.
748+
749+
Specific behaviors of the priority inheritance mechanism to keep in mind:
750+
* A task can have its inherited priority raised further if it
751+
takes a mutex without first releasing mutexes it already holds.
752+
* A task remains at its highest inherited priority until
753+
it has released all the mutexes it holds. This is regardless of
754+
the order the mutexes are released.
755+
* A task will remain at the highest inherited priority if multiple
756+
mutexes are held regardless of tasks waiting on any of the held
757+
mutexes completing their wait (timing out).
758+
740759
741760
### 8.3.4 Deadlock (or Deadly Embrace)
742761

0 commit comments

Comments
 (0)