typedef shared int mutex; LOCK(mutex *lock) do old = TestAndSet(lock); while (old == 1) UNLOCK(mutex *lock) *lock = 0