source: CIVL/examples/concurrency/spawn2.cvl

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 509 bytes
RevLine 
[20d2740]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 */
[e6b02c8]6#include<civlc.cvh>
[20d2740]7
[0baeebd]8$input int N = 10;
[20d2740]9int s1, s2;
10
11void f1(int n) {
[8b354468]12 s1 = 0;
13 for (int i=0; i<n; i++) s1 += i;
[20d2740]14}
15
16void f2(int n) {
[8b354468]17 s2 = 0;
18 for (int i=0; i<n; i++) s2 += i;
[20d2740]19}
20
21void main() {
22 $proc p = $spawn f1(N);
23 $proc q = $spawn f2(N);
24
[a82987f]25 $wait(p);
26 $wait(q);
[d980649]27 $assert(s1==s2);
[20d2740]28}
Note: See TracBrowser for help on using the repository browser.