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

A counting semaphore was initialized to $10$. Then $6 P$ (wait) operations and $4V$ (signal) operations were completed on this semaphore. The resulting value of the semaphore is

  1. $0$
  2. $8$
  3. $10$
  4. $12$
asked in Operating System by Veteran (52k points)
edited by | 3.5k views

3 Answers

+21 votes
Best answer

Answer is option (B)

Initially semaphore is $10$, then $6$ down operations are performed means $(10-6=4)$ and $4$ up operations means $(4+4=8)$

So, at last option (B) $8$ is correct.

answered by Active (3.3k points)
edited by
+3 votes
6 down and 4 up

that mean we are left with 2 down

and the total is 10 reduce 2 down from it

ans 8
answered by Junior (973 points)
0 votes
The positive value of semaphore shows the number of successful down() that can be performed on the semaphore. Here 6 successful down() can be performed after that semaphore value will become 4. 1 down() decreases the value of semaphore by 1.

The up() on semaphore increases it's value by 1 & it is always successful. After 4 up() final value of semaphore become 8.
answered by (209 points)

Related questions

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
49,536 questions
54,113 answers
71,027 users