LOGBOOK

HELP

Quiz Entry - updated: 2026.09.25

What is the difference between a semaphore, a mutex and a queue in an RTOS?

A semaphore signals that something happened or counts available resources; a mutex gives one task exclusive ownership of a shared resource; a queue passes data between tasks.

All three let tasks coordinate, and all three can make a task block until the thing it waits for is available:

Mechanism Purpose Typical use
Binary semaphore Signalling: "an event happened" An ISR gives it when data arrives; a task waiting on it wakes up
Counting semaphore Counts available units or pending events Three free buffers; five unprocessed button presses
Mutex Mutual exclusion with an owner: only the task that took it may give it back Protecting an I2C bus or a shared struct used by two tasks
Queue Copies data from one task (or ISR) to another in FIFO order A sensor task sends readings to a Wi-Fi upload task

The mutex/semaphore distinction matters. A mutex has an owner, which lets the RTOS apply priority inheritance (see priority inversion) and prevents another task from releasing a lock it doesn't hold. A binary semaphore has no owner, which is exactly what makes it suitable for an ISR to signal a task.

Tip: semaphore = signal, mutex = lock, queue = mailbox.

Go deeper:

From Quiz: SIOT / Real-Time Operating Systems and Task Scheduling | Updated: Sep 25, 2026