OpenMP-Examples/sources/Example_tasking.7.c

30 lines
459 B
C

/*
* @@name: tasking.7c
* @@type: C
* @@compilable: yes
* @@linkable: no
* @@expect: success
*/
int tp;
#pragma omp threadprivate(tp)
int var;
void work()
{
#pragma omp task
{
/* do work here */
#pragma omp task
{
tp = 1;
/* do work here */
#pragma omp task
{
/* no modification of tp */
}
var = tp; //value of tp can be 1 or 2
}
tp = 2;
}
}