Hire Our Expert Programmer & Technical Writer To Do Your Capstone Project
+1 vote
in Compilers & Operating Systems by

1 Answer

+1 vote
selected by (user.guest)
Best answer


For the solution to the critical section problem one synchronization tool is used which is known as semaphores. A semaphore ‘S’ is an integer variable which is accessed through two standard operations such as wait and signal. These operations were originally termed ‘P’ (for wait means to test) and ‘V’ (for single means to increment). The classical definition of wait is  

 Wait (S)


 While (S <= 0)






The classical definition of the signal is

 Signal (S)




In case of wait the test condition is executed with interruption and the decrement is executed without interruption.  

Binary Semaphore:

A binary semaphore is a semaphore with an integer value which can range between 0 and 1.

Let ‘S’ be a counting semaphore. To implement the binary semaphore we need following the structure of data.  

Binary Semaphores S1 , S2 ;  

int C;

Initially S1 = 1, S2 = 0 and the value of C is set to the initial value of the counting semaphore ‘S’.  

Then the wait operation of the binary semaphore can be implemented as follows.

Wait (S1



if (C < 0)


 Signal (S1


 Wait (S2


}Signal (S1


The signal operation of the binary semaphore can be implemented as follows:

Wait (S1 );  


if (C <=0)

Signal (S2 );  


Signal (S1


Welcome to CPENTalk.com

Disclaimer: Every user is solely responsible for anything that he/she posts or uploads on CPENTalk.