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

main test-branch
Last change on this file since bd7a43e 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: 625 bytes
Line 
1/* Commandline execution:
2 * civl verify atomicBlockResume.cvl
3 * */
4#include <civlc.cvh>
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 $yield();
17 $when(x==0)
18 switch(y) {
19 case 1: sum += 1*i; break;
20 case 2: sum += 2*i; break;
21 case 3: sum += 3*i; break;
22 };
23 }
24}
25
26void main(){
27 $proc fp1, fp2;
28
29 $atomic {
30 fp1 = $spawn foo(1);
31 fp2 = $spawn foo(2);
32 // blocked here until z++ has been executed twice
33 $yield();
34 $when (z==2) x = 0;
35 }
36 $wait(fp1);
37 $wait(fp2);
38}
Note: See TracBrowser for help on using the repository browser.