[Algorithm 4 from 1st edition of text]
Requires an array of boolean values.
repeat         flag[i] := true;         while flag[j] do                 begin                         flag[i] := false;                         while flag[j] do no-op;                         flag[i] := true;                 end;                 critical section         flag[i] := false;                 remainder section until false; |
This algorithm can suffer starvation if both processes alternate in a certain pattern.