The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
1.5k views

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:

  1. P2 needs to access
  2. P1 needs to access
  3. P3 needs to access
  4. P2 exits critical section
  5. Pi exits critical section

The final value of semaphore will be:

  1. 0
  2. 1
  3. -1
  4. -2
asked in CBSE/UGC NET by Active (3.9k points) | 1.5k views

3 Answers

+3 votes
Best answer

initial value of semaphores S=1

  1. P2 needs to access decreases it to 0    (no one is waiting)
  2. P1 needs to access decreases it to -1   (one process is waiting)
  3. P3 needs to access decreases it to -2 ( 2 process r waiting)
  4. P2 exits critical section increases it to -1 ( one process is waiting)
  5. Pi exits critical section increases it to 0   ( no process is waiting)                                                                                                                    so ans is A
answered by Boss (49.6k points)
selected by
+1 vote

Initially the value of semaphore S is 1.

After (a) S=0
(b) S=-1
(c) S= -2
(d) S= -1
(e) S= 0

  ans is A

answered by Active (1.7k points)
0
3 process operation

So initial value is 1-3+2=0

 

Ans is A
0 votes
3 p operation and 2 v operation , so initial value is 1 -3+2=0
answered by Active (4.9k 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

42,599 questions
48,600 answers
155,664 comments
63,733 users