source: CIVL/examples/languageFeatures/atomicBlockedResume.cvl@ 44a7259

1.23 2.0 main test-branch
Last change on this file since 44a7259 was 36b5ada, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

Cleaned up examples.

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

  • Property mode set to 100644
File size: 524 bytes
Line 
1/* Commandline execution:
2 * civl verify atomicBlockResume.cvl
3 * */
4#include <civlc.h>
5
6int x = 1;
7int y = 0;
8int z = 0;
9int sum = 0;
10
11void foo(int i) {
12 $atomic {
13 y = y + i;
14 z++;
15 // blocked here until x is set to 0
16 $when(x==0)
17 switch(y) {
18 case 1: sum += 1*i; break;
19 case 2: sum += 2*i; break;
20 case 3: sum += 3*i; break;
21 };
22 }
23}
24
25void main(){
26 $atomic {
27 $spawn foo(1);
28 $spawn foo(2);
29 // blocked here until z++ has been executed twice
30 $when (z==2) x = 0;
31 }
32}
Note: See TracBrowser for help on using the repository browser.