source: CIVL/examples/concurrency/spawn2.cvl@ 23207c6

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 23207c6 was 2fa36af, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

make examples atomic

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

  • Property mode set to 100644
File size: 511 bytes
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.h>
7
8$input int N;
9int s1, s2;
10
11void f1(int n) {
12$atomic{
13 s1 = 0;
14 for (int i=0; i<n; i++) s1 += i;}
15}
16
17void f2(int n) {
18$atomic{
19 s2 = 0;
20 for (int i=0; i<n; i++) s2 += i;}
21}
22
23void main() {
24 $proc p = $spawn f1(N);
25 $proc q = $spawn f2(N);
26
27 $wait p;
28 $wait q;
29 $assert s1==s2;
30}
Note: See TracBrowser for help on using the repository browser.