-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from utwente-fmt/fork-examples
Fork examples
- Loading branch information
Showing
3 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//:: cases ForkPVLFail | ||
//:: tools silicon | ||
//:: verdict Fail | ||
|
||
class Test { | ||
|
||
Test() {} | ||
|
||
requires true; | ||
ensures true; | ||
void run(){ | ||
|
||
} | ||
|
||
void test2(){ | ||
Test t1=new Test(); | ||
fork t1; | ||
fork t1; | ||
|
||
} | ||
|
||
void test3(){ | ||
Test t1=new Test(); | ||
join t1; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//:: cases ForkJoinLoopPVL | ||
//:: tools silicon | ||
//:: verdict Pass | ||
|
||
class MainFJ { | ||
|
||
|
||
static void MainFJ(seq<int> nodes) { | ||
seq<NodesThread> nodeThreads = seq<NodesThread> {}; | ||
|
||
loop_invariant 0 <= i && i <= |nodes|; | ||
loop_invariant |nodeThreads| == i; | ||
loop_invariant (\forall* int j=0..|nodeThreads|; idle(nodeThreads[j])); | ||
loop_invariant (\forall* int j=0..|nodeThreads|; Perm(nodeThreads[j].val,1)); | ||
for(int i = 0; i < |nodes|; i++) { | ||
NodesThread node = new NodesThread(nodes[i]); | ||
nodeThreads = nodeThreads ++ node; | ||
assert idle(nodeThreads[i]); | ||
} | ||
|
||
assert (\forall* int j=0..|nodeThreads|; Perm(nodeThreads[j].val,1)); | ||
assert (\forall* int j=0..|nodeThreads|; idle(nodeThreads[j])); | ||
|
||
loop_invariant 0 <= i && i <= |nodes|; | ||
loop_invariant (\forall* int j=i..|nodeThreads|; idle(nodeThreads[j])); | ||
loop_invariant (\forall* int j=0..i; running(nodeThreads[j])); | ||
loop_invariant (\forall* int j=0..|nodeThreads|; Perm(nodeThreads[j].val,1)); | ||
for(int i = 0; i < |nodes|; i++) { | ||
assert idle(nodeThreads[i]); | ||
fork nodeThreads[i]; | ||
assert running(nodeThreads[i]); | ||
} | ||
|
||
assert (\forall* int j=0..|nodeThreads|; running(nodeThreads[j])); | ||
|
||
loop_invariant 0 <= i && i <= |nodes|; | ||
loop_invariant |nodeThreads| == |nodes|; | ||
loop_invariant (\forall* int j=i..|nodeThreads|; running(nodeThreads[j])); | ||
loop_invariant (\forall* int j=0..i; idle(nodeThreads[j])); | ||
for(int i = 0; i < |nodes|; i++) { | ||
assert running(nodeThreads[i]); | ||
join nodeThreads[i]; | ||
assert idle(nodeThreads[i]); | ||
} | ||
} | ||
} | ||
|
||
class NodesThread { | ||
|
||
int val; | ||
|
||
ensures Perm(val,1); | ||
NodesThread(int v) { | ||
val = v; | ||
} | ||
|
||
void run() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters