source: CIVL/examples/languageFeatures/yieldTest/local_yield_and_block.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: 555 bytes
Line 
1/* Threads t0 and t1 are all wrapped in $local_begin and $local_end.
2 With $yield, both interleaves: t0 first then t1 and the other way
3 around will be explored by CIVL. However, since t1 will be
4 blocked until t0 terminates. The final value of x is still
5 deterministic.
6 */
7
8int x = -1;
9int y = 0;
10void thread(int tid) {
11 $local_start();
12 if (tid == 1) {
13 $yield();
14 $when(y == 1);
15 }
16 x = tid;
17 $yield();
18 if (tid == 0)
19 y = 1;
20 $local_end();
21}
22
23int main() {
24 $parfor (int i : 0 .. 1)
25 thread(i);
26 $assert(x == 1);
27}
Note: See TracBrowser for help on using the repository browser.