n An algorithm that uses
testset for Mutual
Exclusion:
n Shared variable b is
initialized to 0
n Only the first Pi who sets
b enter CS
n A C++  description of
test-and-set:
bool testset(int& i)
{
  if (i==0) {
    i=1;
    return true;
  } else {
    return false;
  }
}
Process Pi:
repeat
  repeat{}
  until testset(b);
     CS
  b:=0;
     RS
forever