source: CIVL/examples/languageFeatures/atomicBlockedResume.cvl@ a8ca3d3

1.23 2.0 main test-branch
Last change on this file since a8ca3d3 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
RevLine 
[36b5ada]1/* Commandline execution:
2 * civl verify atomicBlockResume.cvl
3 * */
[2c448829]4#include <civlc.h>
5
6int x = 1;
7int y = 0;
8int z = 0;
9int sum = 0;
10
[36b5ada]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 }
[2c448829]23}
24
25void main(){
[36b5ada]26 $atomic {
[2c448829]27 $spawn foo(1);
28 $spawn foo(2);
[36b5ada]29 // blocked here until z++ has been executed twice
[2c448829]30 $when (z==2) x = 0;
[36b5ada]31 }
[2c448829]32}
Note: See TracBrowser for help on using the repository browser.