source:
CIVL/mods/dev.civl.com/examples/omp/atomics/atomic_read_write.c@
bc0fbae
| Last change on this file since bc0fbae was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 293 bytes | |
| Line | |
|---|---|
| 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.
