Skip to content

Commit 11c7cd8

Browse files
authored
Adding Barrier synchronization and Auxiliary Variable examples (#177)
Signed-off-by: JarodDif <jarod.differdange@gmail.com>
1 parent 0b69aea commit 11c7cd8

14 files changed

Lines changed: 2406 additions & 0 deletions

File tree

.ciignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ specifications/CCF
1111
specifications/azure-cosmos-tla
1212
specifications/microwave
1313

14+
# Basic contribution only
15+
specifications/barriers
16+
specifications/locks_auxiliary_vars
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONSTANT N = 6
2+
SPECIFICATION Spec
3+
INVARIANT TypeOK
4+
PROPERTY BarrierProperty
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
------------------------------- MODULE Barrier --------------------------------
2+
EXTENDS Integers
3+
4+
CONSTANTS
5+
N
6+
7+
VARIABLES pc
8+
9+
vars == << pc >>
10+
11+
ProcSet == (1..N)
12+
13+
Init ==
14+
/\ pc = [p \in ProcSet |-> "b0"]
15+
16+
b0(self) ==
17+
/\ pc[self] = "b0"
18+
/\ pc' = [pc EXCEPT ![self] = "b1"]
19+
20+
b1 ==
21+
/\ \A p \in ProcSet : pc[p] = "b1"
22+
/\ pc' = [p \in ProcSet |-> "b0"]
23+
24+
Next ==
25+
\/ \E p \in ProcSet : b0(p)
26+
\/ b1
27+
28+
Spec == Init /\ [][Next]_vars
29+
30+
-------------------------------------------------------------------------------
31+
32+
TypeOK ==
33+
/\ pc \in [ProcSet -> {"b0", "b1"}]
34+
35+
\* A process cannot leave the barrier if there are still other processes
36+
\* that need to enter it
37+
BarrierProperty ==
38+
/\ [][\A p,q \in ProcSet : pc[p] = "b0" /\ pc[q] = "b1" => pc'[q] = "b1"]_vars
39+
40+
===============================================================================
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONSTANT N = 6
2+
SPECIFICATION Spec
3+
INVARIANTS TypeOK LockInv Inv FlushInv
4+
PROPERTY BSpec

0 commit comments

Comments
 (0)