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:
488 bytes
|
| Line | |
|---|
| 1 | #include<civlc.cvh>
|
|---|
| 2 |
|
|---|
| 3 | /* A deadlock should be possible in this program as follows:
|
|---|
| 4 | * p1: x=1, then blocks at $when(x==2), losing atomic lock.
|
|---|
| 5 | * p2: $when(x==1); x=2, x=4; terminates.
|
|---|
| 6 | * at this point p1 is blocked, as is main.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | int x=0;
|
|---|
| 10 |
|
|---|
| 11 | void p1() {
|
|---|
| 12 | $atomic {
|
|---|
| 13 | x=1;
|
|---|
| 14 | $when(x==2);
|
|---|
| 15 | x=3;
|
|---|
| 16 | }
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | void p2() {
|
|---|
| 20 | $when(x==1);
|
|---|
| 21 | x=2;
|
|---|
| 22 | x=4;
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | void main() {
|
|---|
| 26 | $proc proc1 = $spawn p1();
|
|---|
| 27 | $proc proc2 = $spawn p2();
|
|---|
| 28 |
|
|---|
| 29 | $wait(proc1);
|
|---|
| 30 | $wait(proc2);
|
|---|
| 31 | $assert((x==4)); // false
|
|---|
| 32 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.