Before returning, a wait function modifies the state of some types of synchronization objects. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one. Mutexes can also be given unique names with which to identify them. The state of a mutex object is signaled when it is not owned by any thread.
Semaphores build on the functionality of mutexes while adding one important feature.
They offer the capability of resource counting so that a pre-determined number of threads can enter synchronized pieces of code at one time. For example, lets say that a computer has three serial ports. This situation provides a perfect opportunity to use a semaphore. To monitor serial port usage, you can create a semaphore with a count of 3 one for each serial port. A semaphore is signaled when its resource count is greater than 0 and non-signaled when the count is equal to 0.