edited by
321 views
3 votes
3 votes

Consider the following process synchronization program involving $N$ processes.

semaphore S = 21;
Process 1
S.signal();
while (1) {
  // do something
  S.wait();
  //critical section
  S.signal(); 
  // do something
}
Process 2..N
while (1) {
  // do something
  S.wait();
  //critical section
  S.signal(); 
  // do something
}


The maximum number of processes that can be in the critical section at any moment of time is _______

  1. $21$
  2. $22$
  3. $23$
  4. More than $23$
edited by

1 Answer

Best answer
4 votes
4 votes
Here, process $1$ is doing an extra signal at first making the semaphore value $22.$ In the while loop all the processes are doing a wait and signal alternatively. So, at maximum, $22$ processes can do a wait and enter the critical section.
selected by
Answer:

Related questions

5 votes
5 votes
1 answer
1
3 votes
3 votes
1 answer
2