feat: add lab-rv32i-freertos-mutex card

This commit is contained in:
user
2026-07-21 19:14:19 +02:00
commit 6419a78ff6
67 changed files with 37023 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
# K11 — Mutex, LockGuard and priority inheritance
## Position
- Series: FreeRTOS C++
- Lesson: L10, card K11
- Duration: 30 minutes
- Actors: LOW=1, MEDIUM=2, HIGH=3, coordinator=4
- Storage: static mutex control and static task stacks
## Outcome
The student distinguishes mutex ownership from semaphore signaling, repairs
early returns with `LockGuard`, and explains every state/priority transition in
a measured priority-inheritance schedule.
## Lesson plan
| Time | Mode | Evidence |
| --- | --- | --- |
| 05 | ownership | owner-only give; ordinary mutex non-recursive |
| 510 | LockGuard | three returns each give exactly once |
| 1015 | setup | LOW takes; HIGH attempts; MEDIUM ready |
| 1520 | inheritance | HIGH blocked; LOW priority rises 1→3 |
| 2025 | release | MEDIUM has not run; HIGH acquires next |
| 2530 | restore | LOW returns to 1; protected counter is 11 |
## Acceptance
- mutex handle equals caller static control and heap delta is zero;
- LOW owns at first checkpoint and HIGH owns after handoff;
- HIGH is blocked while waiting;
- LOW priority is exactly 1, then 3, then 1;
- MEDIUM does not run before LOW release;
- event order proves inherited LOW precedes MEDIUM;
- guard restores on every host early-return path;
- ordinary recursive attempt fails;
- target exits with PASS and shared counter 11.
## Main traps
1. A binary semaphore is not an ownership mutex and has no inheritance.
2. Ordinary mutex recursion deadlocks/fails; use a recursive type deliberately.
3. Only the owner may unlock.
4. Mutex APIs are not ISR APIs.
5. Inheritance is temporary and bounded by the held mutex lifetime.