📜  openmp 锁 - 任何代码示例

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

代码示例1
omp_lock_t writelock;

omp_init_lock(&writelock);

#pragma omp parallel for
for ( i = 0; i < x; i++ )
{
    // some stuff
   omp_set_lock(&writelock);
    // one thread at a time stuff
    omp_unset_lock(&writelock);
    // some stuff
}

omp_destroy_lock(&writelock);