绕口令:A process PPP can enter the critical section if the other does not want to enter, otherwise it may enter only if it is its turn.
还是绕口令:A process PPP can enter the critical section if the other does not want to enter, or it has indicated its desire to enter and has given the other process the turn.
a = 1; // 举起自己的旗子 turn = B; // 贴上对方的名字 do { // 进入持续观察模式 } while (b && turn == B); // 对方举旗且门上是对方的的名字 // 临界区 a = 0; // 放下自己的旗子
b = 1; turn = A; do { } while (a && turn == A); // 临界区 b = 0;
__sync_synchronize()
mfence
dmb ish
fence rw, rw