1.

What do you mean by Semaphore in OS? Why is it used?

Answer»

SEMAPHORE is a signaling mechanism. It only holds one positive integer value. It is simply used to solve the problem or issue of critical sections in the synchronization process by using two atomic operations i.e., wait() and signal(). 

Types of Semaphore
There are usually two types of semaphores as given below:

  • Binary Semaphore
  • Counting Semaphore
Binary SemaphoreMutex
It allows various process threads to GET the finite instance of the resource until resources are available.It allows various process threads to get single SHARED resource only at a time.
Its functions are based upon signaling mechanisms.Its functions are based upon a locking mechanism.
Binary semaphores are MUCH faster as COMPARED to Mutex.Mutex is slower as compared to binary semaphores.
It is basically an integer.It is basically an object.


Discussion

No Comment Found