A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Discussion Forum

Que. There are three processes P1, P2 and P3 sharing a semaphore for synchronising a variable. Initial value of semaphore is one. Assume that negative value of semaphore tells us how many processes are waiting in queue. Processes access the semaphore in following order:

(a) P2 needs to access
(b) P1 needs to access
(c) P3 needs to access
(d) P2 exits critical section
(e) Pi exits critical section

The final value of semaphore will be:
a. 0
b. 1
c. -1
d. -2
Answer:0
Ashu :(May 15, 2019) I want to know answer explanation
Click to Add Comment

Shri :(June 06, 2019) Needs to access the critical section means P( ) operation on Semaphore
exit critical section means V( ) operation on Semaphore.
given that intial value of semaphore = 1
final value of semaphore = Initial value - No.of P() operations + No.of V() operations
= 1-3 +2
= 0
Click to Add Comment

Confused About the Answer? Ask for Details Here
Know Explanation? Add it Here

Similar Questions: