int status = ; void lock() { retry: if (status != ) { goto retry; } status = ; } void unlock() { status = ; }
retry: if (status != ) { goto retry; } status = ;
asm volatile("lock incq %0" : "+m"(sum));
int status = ; void lock() { retry: int got = atomic_xchg(&status, ); if (got != ) { goto retry; } } void unlock() { atomic_xchg(&status, ); }