© Thomas Kunz 2000
SCE 574
209
Software Solutions:
Algorithm 2
äKeep 1  Bool variable for each process: flag[0] and flag[1]
äPi signals that it is ready to enter it’s CS by: flag[i]:=true
äMutual Exclusion is satisfied but not the progress requirement
äIf we have the sequence:
äT0: flag[0]:=true
äT1: flag[1]:=true
äBoth process will wait forever to enter their CS: we have a deadlock
ä
Process Pi:
repeat
  flag[i]:=true;    while(flag[j]){};
     CS
  flag[i]:=false;
     RS
forever