mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-07 23:22:11 +01:00
34 lines
453 B
C
34 lines
453 B
C
/*
|
|
* @@name: lock_owner.1c
|
|
* @@type: C
|
|
* @@compilable: yes
|
|
* @@linkable: yes
|
|
* @@expect: success
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <omp.h>
|
|
|
|
int main()
|
|
{
|
|
int x;
|
|
omp_lock_t lck;
|
|
|
|
omp_init_lock (&lck);
|
|
omp_set_lock (&lck);
|
|
x = 0;
|
|
|
|
#pragma omp parallel shared (x)
|
|
{
|
|
#pragma omp master
|
|
{
|
|
x = x + 1;
|
|
omp_unset_lock (&lck);
|
|
}
|
|
|
|
/* Some more stuff. */
|
|
}
|
|
omp_destroy_lock (&lck);
|
|
return 0;
|
|
}
|