\"\" \"\" \"\"
Go backward to Synchronization Mechanisms
Go up to Top
Go forward to Shared Memory Synchronization
RISC-Linz logo

Lock Variables

Implementation by "Test&Set" operation
typedef shared int mutex;
LOCK(mutex *lock)
  do
    old = TestAndSet(lock);
  while (old == 1)
UNLOCK(mutex *lock)  
  *lock = 0
Constant polling of lock variable!
Author: Wolfgang Schreiner
Last modification: November 15, 1996