Binary Semaphore

Question-

A Binary Semaphore variable mutex is initilized to '1'. and the various binary semaphore operations like 9down(),14up(),6down(),8up(),3down(),2up() are performed,then what is the final value of binary semaphore variable mutex. 

 

3Comments
Arjun @arjunsinghra
9 Dec 2016 05:51 pm

I am getting '0' am i correct

Sumit Verma @sumitkgp
9 Dec 2016 06:18 pm

.

Arjun @arjunsinghra
9 Dec 2016 06:14 pm

s=1;

1) 9 down()

s=0(1 down operation-1 times call) 

8 down operations 8 processes go to suspend list

2) 14 up()

8 processes wakeup from suspend list after 8 up operations

s=1 (6-up operations -6 times call)

3) 6 down()

s=0 (1 down operation-1 times call) 

5 down operations 5 processes go to suspend list

4) 8up()

5 processes wakeup from suspend list after 5 up operations

s=1(3-up operations -3 times call)

5) 3 down()

s=0(1 down operation-1 times call) 

2 down operations 2 processes go to suspend list

6) 2 up()

2 processes wakeup from suspend list after 2 up operations

s=0 

what is incorrect then in this procedure