How does a mutex lock differ from a binary semaphore?
Correct answer A. A mutex has an owner and should be released only by the thread that locked it, while a semaphore can be signalled by any thread
Both allow one holder at a time, but a mutex has ownership: the thread that acquires it is the one expected to release it, and POSIX error-checking mutexes report an unlock by a non-owner. A semaphore has no owner, so one thread can wait and another signal, which suits signalling between threads. Counting several resources is what a counting semaphore does.
Answer checked How we write and check questions
Discussion