Semaphores, counting semaphores, binary semaphores in Operating systems OS

What are semaphores?

  • Semaphores are the variables.
  • Semaphores are used for signaling among processes.
  • Three kinds of operations are performed on semaphores;
    1. To initialize the semaphore
    2. To increment the semaphore value
    3. To decrement the semaphore value

What are binary semaphores?

  • Binary semaphores take only the values in between 0 to 1.

What are counting semaphores?

  • Counting semaphores have the non-negative integer value.

How can processes get the critical section?

  • Critical section is controlled by semaphores by following operations;
    • Wait: Any process can’t enter into the critical section.
      • Semaphore value is decremented.
    • Signal: Process can enter into the critical section.
      • Semaphore value is incremented.


difference between binary and counting semaphores

[quads id=2]
counting semaphore example in os
Figure: Binary semaphores