-
Notifications
You must be signed in to change notification settings - Fork 2
/
OneBitClock.tla
67 lines (50 loc) · 1.27 KB
/
OneBitClock.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---------------------------- MODULE OneBitClock ----------------------------
EXTENDS Naturals, Integers, FiniteSets, Bags, Sequences, TLC
Put(s) == Append(s, "widget")
Get(s) == Tail(s)
(*
--fair algorithm OneBitClock {
variable b = 0 , box = << >> ;
process(Producer = 0) {
p1:
while (TRUE) {
await b = 0 ;
box := Put(box) ;
b := 1;
print <<0,b,box>>;
}
}
process (Consumer = 1) {
c1:
while (TRUE) {
await b = 1 ;
box := Get(box) ;
b := 0;
print <<1,b,box>>;
}
}
}
*)
\* BEGIN TRANSLATION
VARIABLES b, box
vars == << b, box >>
ProcSet == {0} \cup {1}
Init == (* Global variables *)
/\ b = 0
/\ box = << >>
Producer == /\ b = 0
/\ box' = Put(box)
/\ b' = 1
/\ PrintT(<<0,b',box'>>)
Consumer == /\ b = 1
/\ box' = Get(box)
/\ b' = 0
/\ PrintT(<<1,b',box'>>)
Next == Producer \/ Consumer
Spec == /\ Init /\ [][Next]_vars
/\ WF_vars(Next)
\* END TRANSLATION
=============================================================================
\* Modification History
\* Last modified Fri Mar 27 09:24:54 CET 2015 by bela
\* Created Thu Mar 26 18:33:13 CET 2015 by bela