Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 26 lines (18 sloc) 0.457 kb
b34beb7 @inducer Add lec 2 demos.
inducer authored
1
2 #include <stdio.h>
3 #include <omp.h>
4
5 omp_lock_t my_lock;
6
7 int main() {
8 omp_init_lock(&my_lock);
9
10 #pragma omp parallel
11 {
12 int tid = omp_get_thread_num( );
13 int i, j;
14
15 for (i = 0; i < 5; ++i) {
16 omp_set_lock(&my_lock);
17 printf("Thread %d - starting locked region\n", tid);
18
19 printf("Thread %d - ending locked region\n", tid);
20 omp_unset_lock(&my_lock);
21 }
22 }
23
24 omp_destroy_lock(&my_lock);
25 }
Something went wrong with that request. Please try again.