in Operating System closed by
1,530 views
0 votes
0 votes
closed as a duplicate of: GATE CSE 2023 | Question: 28


incr()
{
    wait(s)
    x = x+1
    signal(s)
 }
 decr()
 {
    wait(s)
    x = x–1
    signal(s)
 }

Shared integer variable $\mathrm{x}$ initialized with $10.$
There are five threads which are calling incr() and there are three threads which are calling decr().
For binary semaphore $\mathrm{s}=1$ minimum possible value of $\mathrm{x}$ is $\mathrm{V}_1$
For counting semaphore $s=2$ minimum possible value of $\mathrm{x}$ is $\mathrm{V}_2$
  1. $15,8$
  2. $12,8$
  3. $15,7$
  4. $12,7$
in Operating System closed by
1.5k views

2 Comments

Was this a 1 mark question or 2 marks?
0
0

Answer is 12,7. 

Find Detailed Explanation here:

Semaphore Question, Binary & Counting Semaphore

0
0

1 Answer

0 votes
0 votes
here one option is  ( 7,7)

explaination  run 2 times decrement  completly  so it become 8 and  upto write operation last  one so it will become 7 but 7 is not update it stored in reg.  now rul completly 5 increment whatever we got  it will update it to 7, so minimum value will me 7.

am i correct

@goclasses

@deepakpoonia

2 Comments

@Deepak Poonia  @GO Classes @Sachin Mittal 1     sir may be this is true  7,7

0
0

Answer is 12,7. 

Find Detailed Explanation here:

Semaphore Question, Binary & Counting Semaphore

1
1