6 votes 6 votes A counting semaphore was initialized t o $7$. Then $\text{20 P (wait)}$ operations and$\text{x V (signal)}$ operations were completed on this semaphore. If the final value of semaphore is $5$, then the value $x$ will be $0$ $13$ $18$ $5$ Operating System isrodec2017 semaphore + – gatecse asked Dec 17, 2017 recategorized Feb 9, 2018 by srestha gatecse 3.1k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply sachin! commented Dec 20, 2017 reply Follow Share option c 0 votes 0 votes REGGIE S commented Jan 2, 2018 reply Follow Share answer key they have given as b.. 0 votes 0 votes sh!va commented Jan 10, 2018 reply Follow Share In revised key answer is changed to C 0 votes 0 votes akash.dinkar12 commented Mar 19, 2018 reply Follow Share Shiva Give me link of revised answer key?? 0 votes 0 votes Please log in or register to add a comment.
Best answer 2 votes 2 votes Counting semaphore is a protected variable whose value can be changed only by predefined atomic operations Wait :- P(Sem s) Decrements value of S by 1. If S<=0, the thread must go for sleep and get inserted in wait_queue Signal: V(Sem s) Increments value of S by 1 and wakes up one of the threads in waiting queue. In given problem Initially value = 7 After 20 P (wait) operations, value = 7- 20 = -13 After x V (signal) operations, value = -13+x =5 x = 5+13 =18 Answer is C sh!va answered Jan 10, 2018 selected Apr 5, 2018 by Arjun sh!va comment Share Follow See all 0 reply Please log in or register to add a comment.
6 votes 6 votes it should be 18 P refers to down operation and V refers to up i.e 7-20(P)+x(V)=5 => x = 18 Priyank Rai 18 answered Dec 22, 2017 Priyank Rai 18 comment Share Follow See all 4 Comments See all 4 4 Comments reply Anu007 commented Dec 22, 2017 reply Follow Share explain a bit. 0 votes 0 votes Priyank Rai 18 commented Dec 22, 2017 reply Follow Share P refers to down operation and V refers to up i.e 7-20(P)+x(V)=5 => x = 18 0 votes 0 votes Anu007 commented Dec 22, 2017 reply Follow Share in answer put it 1 votes 1 votes abcd efgh commented Apr 21, 2018 reply Follow Share Smart representation. I'm noting it down as a formula 0 votes 0 votes Please log in or register to add a comment.