Mutexes differ from binary semaphores primarily through the principle of ownership — only the task that locks a mutex can unlock it. This ownership enables several safety features: prevention of accidental release, support for recursive locking, priority inheritance protocols (Basic Priority Inheritance and Priority Ceiling Protocol), and death detection when a task terminates while holding a mutex. However, mutexes do not automatically solve circular deadlock (the 'deadly embrace') or non-cooperative access. The Priority Ceiling Protocol is explained as a way to eliminate the 'hold and wait' deadlock condition. The Monitor pattern — encapsulating shared resources and locking behind a controlled interface — is presented as the solution to non-cooperation. The post also clarifies that not all RTOS mutex implementations support recursion, priority inheritance, or death detection.

11m read timeFrom embeddedrelated.com
Post cover image
Table of contents
Accidental ReleaseRecursive DeadlockPriority InversionDeath DetectionMutual Exclusion / SynchronisationCaveatCircular DeadlockPriority Ceiling ProtocolNon-cooperationThe MonitorFinishing Off
1 Impression