EmbeddedRelated.com
The 2026 Embedded Online Conference
Mutex vs. Semaphore - Part 1

Mutex vs. Semaphore - Part 1

Niall Cooling
TimelessIntermediate

It never ceases to amaze me how often I see postings in forums asking the difference between a semaphore and a mutex. Probably what baffles me more is that over 90% of the time the responses given are either incorrect or missing the key...


Summary

Niall Cooling's blog post clears up common misconceptions about semaphores and mutexes in embedded systems and RTOS environments. Readers will learn the semantic differences, typical use cases, and key pitfalls (ownership, priority inversion, ISR usage) that make choosing the right primitive important.

Key Takeaways

  • Distinguish binary semaphores (signaling) from mutexes (mutual exclusion with ownership).
  • Use mutexes to protect shared resources and rely on priority inheritance where available to avoid priority inversion.
  • Use semaphores for task-to-task or ISR-to-task signaling and invoke the appropriate from-ISR APIs when signaling from interrupts.
  • Avoid using semaphores as locks where ownership matters, and be aware of deadlock and priority-related pitfalls.
  • Understand OS-specific behavior (FreeRTOS, POSIX, embedded Linux) and pick the correct API for your environment.

Who Should Read This

Intermediate embedded firmware engineers and RTOS developers who write or debug concurrency and synchronization in microcontroller, IoT, or embedded Linux projects.

TimelessIntermediate

Topics

RTOSFirmware DesignEmbedded LinuxBare-Metal Programming

Related Documents


The 2026 Embedded Online Conference