source:
CIVL/examples/concurrency/spawn.cvl@
24ca21c
| Last change on this file since 24ca21c was 24ca21c, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 462 bytes | |
| Rev | Line | |
|---|---|---|
| [20d2740] | 1 | /* spawn.cvl: simple example of spawning two processes. |
| 2 | * A good test for reduction: verification should avoid | |
| 3 | * exploring all interleavings. It should in fact | |
| 4 | * reduce to a single interleaving. | |
| 5 | * civl verify -inputN=10 spawn.cvl | |
| 6 | */ | |
| [f28d814] | 7 | #include<civlc.h> |
| [20d2740] | 8 | |
| 9 | $input int N; | |
| 10 | ||
| [34760dc] | 11 | void f(int n) { |
| [20d2740] | 12 | int i = 0; |
| [24ca21c] | 13 | $atomic{ |
| [20d2740] | 14 | for (i=0; i<n; i++) ; |
| [24ca21c] | 15 | $assert i==n;} |
| [34760dc] | 16 | } |
| 17 | ||
| 18 | void main() { | |
| [20d2740] | 19 | $proc p = $spawn f(N); |
| 20 | $proc q = $spawn f(N); | |
| 21 | ||
| [24ca21c] | 22 | $atomic{ |
| [f28d814] | 23 | $wait p; |
| [24ca21c] | 24 | $wait q;} |
| [34760dc] | 25 | } |
Note:
See TracBrowser
for help on using the repository browser.
