1,565 views
0 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 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
Position:
Show:

Related questions

1 1 vote
3 answers 3 answers
2.9k
2.9k views
Aks9639 asked Mar 29, 2019
2,909 views
Q. An SJF algorithm is simply a priority algorithm where the priority is :A) predicted next cpu burst B) The inverse of the predicted next cpu burst C) the current cpu bu...
0 0 votes
0 0 answers
583
583 views
altamash asked Dec 16, 2018
583 views
You have a disk with the following characteristics: Each sector is 512 bytes, it has 1024 sectors per track and 4096 tracks per platter. The disk has total 10 platters(an...
0 0 votes
0 0 answers
578
578 views
saif asked Nov 17, 2018
578 views
Does context switch time depends on scheduling algorithms??
0 0 votes
1 1 answer
1.6k
1.6k views
altamash asked Oct 1, 2018
1,577 views
Assume that a task is divided into four equal-sized segments and that the system builds an eight-entry page descriptor table for each segment. Thus, the system has a comb...