source:
CIVL/examples/omp/atomics/atomic_read_write.c@
afc300c
| Last change on this file since afc300c was 5bea123, checked in by , 7 years ago | |
|---|---|
|
|
| File size: 293 bytes | |
| Rev | Line | |
|---|---|---|
| [5bea123] | 1 | #include<assert.h> |
| 2 | ||
| 3 | int main() { | |
| 4 | int x = 0; | |
| 5 | int y = 0; | |
| 6 | #pragma omp parallel sections | |
| 7 | { | |
| 8 | #pragma omp section | |
| 9 | { | |
| 10 | #pragma omp atomic read | |
| 11 | y = x; | |
| 12 | } | |
| 13 | #pragma omp section | |
| 14 | { | |
| 15 | #pragma omp atomic write | |
| 16 | x = 1 + 1; | |
| 17 | } | |
| 18 | } | |
| 19 | assert (y == 0 || y == 2); | |
| 20 | } |
Note:
See TracBrowser
for help on using the repository browser.
