What is mutex and semaphore?
Mutex stands for mutual exclusion. Mutex is a mutual exclusion object that
allows multiple processes or threads, a synchronized access to shared resources.
A mutex is created with unique name in the program. It has two states; lock and
unlock. Only one thread (or process) can lock a mutex at one time, while the
other threads are blocked. When mutex is unlocked, then one of the blocked
thread locks it.
Semaphore is an integer type protected variable through which the synchronization of
co-operating processes can be controlled. It can easily be implemented in
operating system. It provides general solution for controlling access to
critical section. The value of semaphore may be 0 or greater than 0