# Choosing Between Mutex, Semaphore, and Queue

**URL:** <https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002>\
**Category:** Kernel\
**Created:** [January 22, 2024, 2:41pm UTC](https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002 "2024-01-22T14:41:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gogo00](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Gogo00](https://forums.freertos.org/u/Gogo00)\
**Post date:** [January 22, 2024, 2:41pm UTC](https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002/1 "2024-01-22T14:41:17Z")

</div>

I’ve read many documents about mutex, semaphore, and queue in RTOS, but I’m confused about when to use each. My understanding is that mutex is for protecting one task, semaphore for multiple tasks, and queue for communication without sharing memory. What are your thoughts on choosing between mutex, semaphore, and queue?

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [January 22, 2024, 3:15pm UTC](https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002/2 "2024-01-22T15:15:31Z")

</div>

You want to read this here book:

[161204\_Mastering\_the\_FreeRTOS\_Real\_Time\_Kernel-A\_Hands-On\_Tutorial\_Guide.pdf](https://freertos.org/fr-content-src/uploads/2018/07/161204_Mastering_the_FreeRTOS_Real_Time_Kernel-A_Hands-On_Tutorial_Guide.pdf)  
in particular, chapters 6 and 7.

Or, really, any text book on concurrency.

---

<div class="post-metadata">

**Author:** ![Gogo00](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Gogo00](https://forums.freertos.org/u/Gogo00)\
**Post date:** [January 23, 2024, 8:53am UTC](https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002/3 "2024-01-23T08:53:18Z")

</div>

My current understanding is that Mutex allowing only one task at a time to access it.  
Semaphore allowing multiple tasks to access shared resources concurrently within specified limits.  
queue for communication between tasks, enabling them to share data without direct memory access.  
Could you please review my understanding and correct me if I’m wrong?

---

<div class="post-metadata">

**Author:** ![RAc](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rac/32/1389_2.png) [@RAc](https://forums.freertos.org/u/RAc)\
**Post date:** [January 23, 2024, 9:02am UTC](https://forums.freertos.org/t/choosing-between-mutex-semaphore-and-queue/19002/4 "2024-01-23T09:02:11Z")

</div>

Do read the chapters I pointed out in the book. That will answer your questions.
