Skip to content

Commit

Permalink
1 var mutex example
Browse files Browse the repository at this point in the history
  • Loading branch information
septract committed Jun 7, 2017
1 parent 181b6b2 commit e4ead25
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Examples/WIP/mutex1var.cvf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
shared int x; // two shared vars
thread int xl; // local copies

shared bool lock; // True iff the lock is taken.
thread bool test; // Used when trying to take the lock.

method setTest(int v) {
{| emp |}
lock();
{| holdLock() |}
<| x = v; |>
{| holdLock() * xVal(v) |}
<| xl = x; |>
{| holdLock() * xVal(v) * local{ xl == v } |}
if (xl != v) {
{| false |}
<| error; |>
{| false |}
}
{| holdLock() |}
unlock();
{| emp |}
}


constraint holdLock() * holdLock() -> false;

constraint xVal(int v) -> x == v;

0 comments on commit e4ead25

Please sign in to comment.