main
test-branch
| Line | |
|---|
| 1 | /* spawn2.cvl: simple example of spawning two processes.
|
|---|
| 2 | * More difficult to reduce than spawn.cvl, because
|
|---|
| 3 | * both are accessing variables in the same scope.
|
|---|
| 4 | * civl verify -inputN=10 spawn2.cvl
|
|---|
| 5 | */
|
|---|
| 6 | #include<civlc.cvh>
|
|---|
| 7 |
|
|---|
| 8 | $input int N = 10;
|
|---|
| 9 | int s1, s2;
|
|---|
| 10 |
|
|---|
| 11 | void f1(int n) {
|
|---|
| 12 | s1 = 0;
|
|---|
| 13 | for (int i=0; i<n; i++) s1 += i;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | void f2(int n) {
|
|---|
| 17 | s2 = 0;
|
|---|
| 18 | for (int i=0; i<n; i++) s2 += i;
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | void main() {
|
|---|
| 22 | $proc p = $spawn f1(N);
|
|---|
| 23 | $proc q = $spawn f2(N);
|
|---|
| 24 |
|
|---|
| 25 | $wait(p);
|
|---|
| 26 | $wait(q);
|
|---|
| 27 | $assert(s1==s2);
|
|---|
| 28 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.