source: CIVL/examples/languageFeatures/atomicBlockedResume.cvl

main
Last change on this file 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
RevLine 
[36b5ada]1/* Commandline execution:
2 * civl verify atomicBlockResume.cvl
3 * */
[e6b02c8]4#include <civlc.cvh>
[2c448829]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
[a3da6fb]16 $yield();
[36b5ada]17 $when(x==0)
[a3da6fb]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 };
[36b5ada]23 }
[2c448829]24}
25
26void main(){
[48bfab9]27 $proc fp1, fp2;
28
[36b5ada]29 $atomic {
[48bfab9]30 fp1 = $spawn foo(1);
31 fp2 = $spawn foo(2);
[36b5ada]32 // blocked here until z++ has been executed twice
[a3da6fb]33 $yield();
[2c448829]34 $when (z==2) x = 0;
[36b5ada]35 }
[48bfab9]36 $wait(fp1);
37 $wait(fp2);
[2c448829]38}
Note: See TracBrowser for help on using the repository browser.