Consider, a taxi that can accommodate a total of 3(rear)+2(front) persons including the driver. So, a semaphore
allows only 5 persons inside a car at a time.
And a mutex
allows only 1 person on a single seat of the car.
Therefore, Mutex
is to allow exclusive access for a resource (like an OS thread) while a Semaphore
is to allow access for n number of resources at a time.