void acquire(lock *lk) { while (test_and_set(&lk->locked) == 1) ; // 自旋等待 } void release(lock *lk) { lk->locked = 0; }