Initial values of S1 ansd S2 are random assigned
Method by P1
do
{
flag[i] = true;
S1 = S2;
while( flag[j]=true and S1 == S2);
critical section
flag[i]=false;
remainder section
}while(1);
Method used by P2
do
{
flag[j]=true;
S1=S2+1;
while(flag[i]=true and S1!=S2);
criticals ection
flag[j]=false;
remainder section
}
while(1);
Does this gurantee mutual exclusion?