source: CIVL/examples/languageFeatures/atomicBlockedResume.cvl@ 96e7e5e

1.23 2.0 main test-branch
Last change on this file since 96e7e5e was 48bfab9, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added checking for memory leak when collecting a dyscope and for process leak when the main process returns; fixed all test cases accordingly; added a filesystem_destroy call for IOTransformer to get rid of memory leak.

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

  • Property mode set to 100644
File size: 585 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 $proc fp1, fp2;
27
28 $atomic {
29 fp1 = $spawn foo(1);
30 fp2 = $spawn foo(2);
31 // blocked here until z++ has been executed twice
32 $when (z==2) x = 0;
33 }
34 $wait(fp1);
35 $wait(fp2);
36}
Note: See TracBrowser for help on using the repository browser.