← BYTES
Unix IPC·Starter·Ref: 15.1.67
What is the basic difference between a binary semaphore and a mutex?
Have a question about this video? Mention reference 15.1.67 when you contact us.
a.They are completely unrelated concepts with no similarities at all
b.A binary semaphore can be acquired by multiple threads at once, while a mutex can only ever be acquired by one thread in its entire lifetime
c.They behave similarly (both can represent an available/unavailable state), but a mutex has the specific notion of OWNERSHIP (only the thread that locked it may unlock it), while a plain semaphore has no ownership concept at all -- any thread may increment (signal) it, not just whoever last decremented (waited on) it
d.A mutex is always slower than a binary semaphore on every system
This is the basic conceptual distinction covered further later: both can represent a simple available/unavailable state, but a mutex specifically tracks an OWNER and generally only lets that owner release it, while a semaphore has no such ownership concept -- any thread can signal (increment) it, regardless of which thread last waited on (decremented) it.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES15167#UnixIPC