n Shared variable b is
initialized to 0
n Each Pi has a local
variable k
n The only Pi that can
enter CS is the one
who finds b=0
n This Pi excludes all
the other Pj by setting
b to 1
Process Pi:
repeat
  k:=1
  repeat xchg(k,b)
  until k=0;
     CS
  b:=0;
     RS
forever