In the standard code for UP operation,
UP (S)
{
if(Waiting queue L is empty)
S = 1;
else
Select a process from waiting queue and wake up();
}
( S is the mutex)
Here, why S=1 is not set in the else part as well?
For eg: if S=0 and many processes are already waiting in the queue, then one other process can still do UP(), make S=1 and enter the critical section right?
ie, shouldn't the "else' part be:
else
{
S = 1;
Select a process from waiting queue and wake up();
}
Or, is it mandatory that a process can enter the critical section only after letting in, all the processes the got blocked before it?