710 views
0 votes
0 votes
Q. The following program consists of 3 concurrent processes and 3 binary semaphore.The semaphore are initialized as s0=1, s1=0, s2=0 .

Process p0

{

    Wait (s0);

Print '0' ;

Release  (s1);

Release (s2);

}

Process p1

Wait (s1);

Release  (s0);

Process p2

Wait (s2);

Release (s0);

How many times will p0 print  '0'?

A) at least twice

B) exactly twice

C)exactly thrice

D)exactly once

My doubt is that , here the processes can also executes  recursively so why they gives ans as "exactly"  term please gives proper explanation my assumption is right or wrong?

1 Answer

4 votes
4 votes

My doubt is that , here the processes can also executes  recursively so why they gives ans as "exactly"  term .

  • only process P0 executes recursively becz of while loop. and process P1 and P2 runs only one time.
  • if we execute this code then it print two zero or three zero .so option b,c,d are false . 
  • option a is right

Related questions

1 votes
1 votes
3 answers
1
0 votes
0 votes
1 answer
2
nikkey123 asked Dec 30, 2017
500 views
Solve the problem please
0 votes
0 votes
0 answers
4
saif asked Nov 17, 2018
278 views
Does context switch time depends on scheduling algorithms??