edited by
517 views
7 votes
7 votes

Consider processes $P_i, i = 1,\dots, 20$ coded as follows:

repeat 
V(mutex)
{Critical section}
P(mutex)
forever


Here, mutex is a binary semaphore initialized to $0.$ The code for $P_{21}$ is identical except it uses $\text{P (mutex)}$ in place of $\text{V (mutex)}$ and vice versa. What is the largest number of processes that can be inside the critical section at any moment ___________

edited by

2 Answers

4 votes
4 votes
Since the first statement for the $20$ processes is $V(mutex)$ or signal, all of them can enter the critical section. If it happens that the $21^{st}$ process comes in between this (before all the $20$ processes does $P$ operation), it is also allowed to enter the critical section. So, at max $21$ processes can be in critical section.
0 votes
0 votes
Since Code not given as for loop etc of the processes from i 1 to 20 ….its only code for every process from 1 to 20, so we may make every other process enter CS whose code is reverse of above then we can have total of maximum 40 processes finally together all in the CS. else if in loop structure its given then it must be only 21 maximum.
Answer:

Related questions

0 votes
0 votes
1 answer
1
ajayraho asked Oct 23, 2022
909 views
What is the significance of infinite loop that is written in every example of process synchronisation? What would happen if there wasn't any infinite loop?