source: CIVL/examples/languageFeatures/yieldTest/local_yield_and_block.cvl@ cc8e265

1.23 2.0 main test-branch
Last change on this file since cc8e265 was 87e98a4, checked in by Ziqing Luo <ziqing@…>, 7 years ago

add $yield implementation

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

  • Property mode set to 100644
File size: 535 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 $when(y == 1);
14 x = tid;
15 $yield();
16 if (tid == 0)
17 y = 1;
18 $local_end();
19}
20
21int main() {
22 $parfor (int i : 0 .. 1)
23 thread(i);
24 $assert(x == 1);
25}
Note: See TracBrowser for help on using the repository browser.