source:
CIVL/mods/dev.civl.com/examples/backend/atomicExample.c@
8553be8
| Last change on this file since 8553be8 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 345 bytes | |
| Line | |
|---|---|
| 1 | #include<stdbool.h> |
| 2 | #include<assert.h> |
| 3 | #include<civlc.cvh> |
| 4 | $input int x; |
| 5 | _Bool b=true; |
| 6 | int a=0; |
| 7 | |
| 8 | void foo(){ |
| 9 | $atomic{ |
| 10 | b=false; |
| 11 | $when(x>0); |
| 12 | b=true; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | void goo(){ |
| 17 | if(!b) |
| 18 | a=1; |
| 19 | } |
| 20 | |
| 21 | void main(){ |
| 22 | $proc pf, pg; |
| 23 | |
| 24 | $atomic{ |
| 25 | pf=$spawn foo(); |
| 26 | pg=$spawn goo(); |
| 27 | } |
| 28 | $wait(pg); |
| 29 | assert(a==0); |
| 30 | assert(b); |
| 31 | $wait(pf); |
| 32 | } |
Note:
See TracBrowser
for help on using the repository browser.
