The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+10 votes

Choose the correct alternatives (more than one may be correct) and write the corresponding letters only:

At a particular time of computation the value of a counting semaphore is 7. Then $20$ $P$ operations and $15$ $V$ operations were completed on this semaphore. The resulting value of the semaphore is :

  1. 42
  2. 2
  3. 7
  4. 12


asked in Operating System by Veteran (68.8k points) | 2.1k views

3 Answers

+20 votes
Best answer
Ans=option B

currently semaphore is 7 so after 20 P(wait) operation it will come to -12 then for 15 V(signal) operation the value comes to 2.
answered by (401 points)
selected by
+9 votes

Option B 

since P(S) decreases the counting semaphore value 

 The initial value of semaphore is 7 

After finishing 20 P operations S=-13 (i.e 7-20 =-13)

Now S=-13

V(S) increases the counting semaphore value

After finishing 15 V operations S=-13+15=2

Therefore Answer is 2 option B


answered by Veteran (14.6k points)
which one is correct?what will be the value after 20 p operations ?

13 or 12 .please answer
+2 votes

 S = 7 - 20 =-13(in suspended list)

S= -13+15 = 2

The resulting value of the semaphore is : 2 option b


suspended list


answered by Loyal (3.3k points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

32,503 questions
39,217 answers
36,599 users