GATE CSE 1992 | Question: 02,x, ISRO2015-35
in Operating System edited by
9,660 views
21 votes

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$
in Operating System edited by
9.7k views

3 Comments

Why Semaphore Wait and Signal Operation Denoted by P and V respectively, specially in ISRO Paper.
0

@pankajbelwal P and V were the terminology used by Dijkstra when he proposed this algorithm. 

2

Subscribe to GO Classes for GATE CSE 2022

4 Answers

32 votes
 
Best answer

The answer is option B.

Currently semaphore is $7$ so, after $20$ $P$(wait) operation it will come to $-13$ then for $15$ V(signal) operation the value comes to $2.$

edited by

1 comment

I think it will be -13

because currently semaphore is 7so, after 20 P(wait or down) operation it will come to −13 (7-20)

and then after 15 V( signal or up) we have 15+(-13) = 2
0
15 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

1 comment

which one is correct?what will be the value after 20 p operations ?

13 or 12 .please answer
0
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
13
0 votes

Current Value of Counting Semaphore : 7

20 P operation, value = 7-20 = -13

15 V operation, values = -13+15 = 2

Answer : (b)2

Answer:

Related questions