source:
CIVL/examples/concurrency/spawn.cvl@
bb03188
| Last change on this file since bb03188 was ea777aa, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 473 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 | */ | |
| [e6b02c8] | 7 | #include<civlc.cvh> |
| [20d2740] | 8 | |
| [0baeebd] | 9 | $input int N = 10; |
| [20d2740] | 10 | |
| [34760dc] | 11 | void f(int n) { |
| [20d2740] | 12 | int i = 0; |
| [2fa36af] | 13 | |
| [8b354468] | 14 | $atomic { |
| 15 | for (i=0; i<n; i++) ; | |
| [d980649] | 16 | $assert(i==n); |
| [8b354468] | 17 | } |
| [34760dc] | 18 | } |
| 19 | ||
| 20 | void main() { | |
| [20d2740] | 21 | $proc p = $spawn f(N); |
| 22 | $proc q = $spawn f(N); | |
| 23 | ||
| [a3da6fb] | 24 | $wait(p); |
| 25 | $wait(q); | |
| [34760dc] | 26 | } |
Note:
See TracBrowser
for help on using the repository browser.
