113
The bakery algorithm (cont.)
Process Pi:
repeat
  choosing[i]:=true;
  number[i]:=max(number[0]..number[n-1])+1;
  choosing[i]:=false;
  for j:=0 to n-1 do {
    while (choosing[j]) {};
    while (number[j]!=0
       and (number[j],j)<(number[i],i)){};
  }
  CS
  number[i]:=0;
  RS
forever