📅  最后修改于: 2022-03-11 14:44:49.455000             🧑  作者: Mango
//d_lock must be initialized to 0
bool success = false;
while(!success) {
if (atomicCAS(&d_lock[i], 0, 1) == 0) {
//critical section
success = true;
atomicExch(&d_lock[i], 0);
}
}