Concept Flow - Recursive mutex for nested locking
Task tries to lock mutex
Is mutex free?
No→Is current task owner?
Increase lock count
Task does work
Task unlocks mutex
Decrease lock count
Is lock count zero?
No→Mutex still owned
Yes
Release mutex ownership
Unblock waiting tasks if any
Done
The task tries to lock the mutex. If free, it locks and sets owner. If already owned by the same task, it increases a count. Unlocking decreases count and releases ownership when count hits zero.
