Assuming you know the main differences between sempahor and mutex:
For quick and easy synchronization, use the critical section.
To synchronize threads across process boundaries, use mutexes.
To synchronize access to limited resources, use a semaphore.
Besides the fact that mutexes have an owner, these two objects can be optimized for different uses. Mutexes are designed to hold only for a short time; Failure to do so may result in reduced productivity and unfair planning. For example, a running thread might be allowed to get a mutex, even if another thread is already locked on it, creating a deadlock . Semaphores can provide more justice, or justice can be invoked with the help of several conditional variables.
source share