void spin_lock(int *mutex) { while(!CAS(mutex, 0, 1)) ; } void spin_unlock(int *mutex) { *mutex = 0; }