Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (18 sloc) 457 Bytes
#include <stdio.h>
#include <omp.h>
omp_lock_t my_lock;
int main() {
omp_init_lock(&my_lock);
#pragma omp parallel
{
int tid = omp_get_thread_num( );
int i, j;
for (i = 0; i < 5; ++i) {
omp_set_lock(&my_lock);
printf("Thread %d - starting locked region\n", tid);
printf("Thread %d - ending locked region\n", tid);
omp_unset_lock(&my_lock);
}
}
omp_destroy_lock(&my_lock);
}
Something went wrong with that request. Please try again.