source:
CIVL/examples/por/loop.cvl
| Last change on this file was ea777aa, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 389 bytes | |
| Rev | Line | |
|---|---|---|
| [fc15297] | 1 | #include<civlc.cvh> |
| 2 | ||
| 3 | int g=0; | |
| 4 | ||
| 5 | void proc0(){ | |
| 6 | int x,y,z; | |
| 7 | ||
| [90561dd] | 8 | $atomic{ |
| 9 | while(1){ | |
| 10 | x=0; | |
| 11 | y=0; | |
| 12 | z=0; | |
| 13 | } | |
| [fc15297] | 14 | } |
| 15 | } | |
| 16 | ||
| 17 | void proc1(){ | |
| 18 | g=1; | |
| [90561dd] | 19 | $assert(g==1); |
| [fc15297] | 20 | } |
| 21 | ||
| 22 | void proc2(){ | |
| 23 | g=2; | |
| [90561dd] | 24 | $assert(g==2); |
| [fc15297] | 25 | } |
| 26 | ||
| 27 | int main(){ | |
| 28 | $proc p0, p1, p2; | |
| 29 | ||
| 30 | $atomic{ | |
| 31 | p0=$spawn proc0(); | |
| 32 | p1=$spawn proc1(); | |
| 33 | p2=$spawn proc2(); | |
| 34 | } | |
| 35 | $wait(p1); | |
| 36 | $wait(p2); | |
| [90561dd] | 37 | $assert(g==0); |
| 38 | $wait(p0); | |
| [fc15297] | 39 | } |
Note:
See TracBrowser
for help on using the repository browser.
