Mutex: a binary lock providing mutual exclusion - exactly one thread can own it. Others block until it is released. It typically has ownership semantics: the locking thread must be the one to unlock.
2 / 5
How does a counting semaphore differ from a mutex?
Semaphore: holds a count of available permits. Up to N threads can acquire concurrently; a thread blocks when the count hits zero. A semaphore initialized to 1 acts like a lock but lacks ownership.
3 / 5
Which has the concept of ownership (the locker must unlock)?
Ownership: a mutex is owned by the thread that locks it, enabling features like recursion and priority inheritance. A semaphore has no owner - any thread can signal (release) it, which makes it suitable for signaling between threads.
4 / 5
A semaphore is often the better tool when you need to do what?
Use cases: semaphores model finite resource pools (allow N concurrent users) and producer-consumer signaling. Mutexes protect a single shared resource where strict mutual exclusion is required.
5 / 5
What is a binary semaphore?
Binary semaphore: a semaphore whose count is 0 or 1. It resembles a mutex but is typically used for signaling (one thread waits, another signals) since it has no ownership requirement.