Mutex as its name suggests provides complete mutual exclusion. At any point of time only one thread can lock a particular mutex.
Sempahore is a non negative integer used when we want more fine grained parallelism. Semaphores are useful when we do not need complete mutual exclusion but want only concurrency control.
Sempahores can be illustrated by the following two major categories:
Producer-Consumer problem where we need synchronization only occasionally(concurrency needed only when the producer is producing at a much higher rate than the consumer can consume or vice versa).
Readers-Writers problem where multiple readers can read at any point of time but only one writer can change the data.