Semaphore and Mutex

A Mutex controls access to a single shared resource. It provides operations to acquire() access to that resource and release() it when done.

A Semaphore controls access to a shared pool of resources. It provides operations to Wait() until one of the resources in the pool becomes available, and Signal() when it is given back to the pool.

There are two types of Semaphores:
  1. Counting Semaphore
  2. Binary Semaphore                                
When number of resources a Semaphore protects is greater than 1, it is called a Counting Semaphore. When it controls one resource, it is called a Binary Semaphore. A Binary semaphore is equivalent to a mutex.

No comments:

Post a Comment