1.23
2.0
main
test-branch
| 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 |
|
|---|
| 8 | int x = -1;
|
|---|
| 9 | int y = 0;
|
|---|
| 10 | void 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 |
|
|---|
| 21 | int 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.