• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
October 27, 2022 |6.6K Views

Semaphores in Operating System

  Share  1 Like
Description
Discussion

In this video, we will be discussing what is semaphores in operating systems.
Semaphores are used to handle concurrent processes during process synchronization.  It is an integer variable which is shared between processes. Semaphores solve the critical section problem in multiprocessing systems. 

Semaphores are of two types: 
1) Binary Semaphores 
2) Counting Semaphores
 
Binary Semaphore: It can take only 2 values: 0 or 1. It is used to implement mutual exclusion among the processes wanting to share the critical section. For this reason, it is also known as a mutex lock. Initially the value of binary semaphore is 1. 

Counting Semaphore: It is used to control sharing of a resource that has multiple instances. The values of a counting semaphore can span an unrestricted range. Only two functions can access and modify the values of semaphores. These are the Wait and Signal operations. 
1) Wait() is also known as Sleep operation or Down operation. 
2) Signal() is also known as Wake-up operation or Up operation. 

Both operations are atomic in nature i.e. when any of these two operations is being performed, they cannot be preempted. 
The Critical Section is surrounded by these two operations. 

Semaphore in OS:
https://www.geeksforgeeks.org/semaphores-in-process-synchronization//