source:
CIVL/examples/locks.cvl@
cffd3a6
| Last change on this file since cffd3a6 was b6565a0, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 368 bytes | |
| Line | |
|---|---|
| 1 | #include<civlc.h> |
| 2 | |
| 3 | int x; |
| 4 | int y; |
| 5 | |
| 6 | void f(int n) { |
| 7 | for (int i=0; i<n; i++) { |
| 8 | $when (x==0) x=1; |
| 9 | $when (y==0) y=1; |
| 10 | y=0; |
| 11 | x=0; |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | void g(int m) { |
| 16 | for (int i=0; i<m; i++) { |
| 17 | $when (y==0) y=1; |
| 18 | $when (x==0) x=1; |
| 19 | x=0; |
| 20 | y=0; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | void main() { |
| 25 | x = 0; |
| 26 | y = 0; |
| 27 | $proc p = $spawn f(10); |
| 28 | $proc q = $spawn g(10); |
| 29 | $wait p; |
| 30 | $wait q; |
| 31 | } |
Note:
See TracBrowser
for help on using the repository browser.
