Skip to content

Commit

Permalink
Refactor and fix environments in modelling.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattWindsor91 committed Feb 3, 2017
1 parent dfeb2c0 commit ca05b5b
Show file tree
Hide file tree
Showing 8 changed files with 267 additions and 188 deletions.
13 changes: 5 additions & 8 deletions Examples/PassGH/arc.cvf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ thread Int c, pval;

method init() {
{| emp |}
// TODO: broken local command syntax.
ret = %{new ArcNode};
<%{[|ret|].count := 1}>;
<{ ret = %{new ArcNode};
%{[|ret|].count := 1}; }>;
{| arc(ret) |}
}

Expand All @@ -33,16 +32,14 @@ method clone(ArcNode x) {

method print(ArcNode x) {
{| arc(x) |}
// TODO: broken local command syntax.
pval = %{ [|x|].val };
<pval = %{ [|x|].val }>;
{| arc(x) |}
}

method drop(ArcNode x) {
{| arc(x) |}
// TODO: broken local command syntax.
c = %{ [|x|].count };
<%{ [|x|].count := [|x|].count - 1 }>;
<{ c = %{ [|x|].count };
%{ [|x|].count := [|x|].count - 1 }; }>;
{| countCopy(x, c) |}
if (c == 1) {
{| countCopy(x, 1) |}
Expand Down
2 changes: 1 addition & 1 deletion Examples/PassGH/clhLock.cvf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ method lock(Node mynode) {
{| queued(mynode, mypred) |}
do {
{| queued(mynode, mypred) |}
test = %{ [|mypred|].lock };
<test = %{ [|mypred|].lock }>;
{| if test then queued(mynode, mypred) else holdLock(mynode, mypred) |}
} while (test);
{| holdLock(mynode, mypred) |}
Expand Down
4 changes: 2 additions & 2 deletions Examples/PassGH/lclist.cvf
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ method deleteVal(int v) {
{| wf(v) * isHead(prev) |}
<{ %{ waitLock([|prev|]); takeLock([|prev|]) }; }>;
{| wf(v) * has1LockAnon(prev) * isHead(prev) |}
curr = %{ [|prev|].next };
< curr = %{ [|prev|].next } >;
{| wf(v) * has1Lock(prev, curr) * isHead(prev) |}
<{ %{ waitLock([|curr|]); takeLock([|curr|]) }; }>;
{| wf(v) * has2Lock(prev, curr) |}
cv = %{ [|curr|].val };
< cv = %{ [|curr|].val } >;
{| wf(v) * has2Lock(prev,curr) * isVal(curr, cv) |}
while (cv < v ) {
{| wf(v) * wf(cv) * has2Lock(prev, curr) * isVal(curr, cv) |}
Expand Down
4 changes: 2 additions & 2 deletions Examples/PassGH/spinLock.cvf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ view newLock(Lock x), holdLock(Lock x), isLock(Lock x);

method newLock() {
{| emp |}
ret = %{new Lock};
<ret = %{new Lock}>;
{| newLock(ret) |}
<%{[|ret|].lock := false}>;
{| isLock(ret) |}
Expand All @@ -25,7 +25,7 @@ method lock(Lock x) {
{| isLock(x) |}
test = false;
{| if test == false then isLock(x) else False() |}
test = %{ CAS_to_true([|x|]) };
<test = %{ CAS_to_true([|x|]) }>;
{| if test == false then isLock(x) else holdLock(x) |}
} while (test == false);
{| holdLock(x) |}
Expand Down
8 changes: 4 additions & 4 deletions Examples/PassGH/ticketLock.cvf
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ view newLock(Lock x), holdTick(Lock x, int t), holdLock(Lock x), isLock(Lock x);

method newLock() {
{| emp |}
ret = %{new Lock};
<ret = %{new Lock}>;
{| newLock(ret) |}
<%{[|ret|].ticket := 0; [|ret|].serving := 0}>;
{| isLock(ret) |}
}

method lock(Lock x) {
{| isLock(x) |}
t = %{ [|x|].ticket };
<%{ [|x|].ticket := [|x|].ticket + 1 }>;
<{ t = %{ [|x|].ticket };
%{ [|x|].ticket := [|x|].ticket + 1 }; }>;
{| holdTick(x, t) |}
do {
{| holdTick(x, t) |}
s = %{ [|x|].serving };
<s = %{ [|x|].serving }>;
{| if s == t then holdLock(x) else holdTick(x, t) |}
} while (s != t);
{| holdLock(x) |}
Expand Down
Loading

0 comments on commit ca05b5b

Please sign in to comment.