📜  cuda 锁 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:49.455000             🧑  作者: Mango

代码示例1
//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);
  }
}