-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPCalBoundedChannel.tla
103 lines (68 loc) · 1.63 KB
/
PCalBoundedChannel.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
------------------------- MODULE PCalBoundedChannel -------------------------
EXTENDS Integers, Sequences
CONSTANTS Msg, \* set of messages
N \* max size of bounded channel
ASSUME /\ N \in Nat \ {0}
/\ Msg # {}
(*
--algorithm PCalBoundedChannel {
variables ch = <<>>; \* the channel
macro Send(m) {
if(Len(ch) < N) {
ch := Append(ch, m);
}
}
macro Recv() {
if(Len(ch) > 0) {
ch := Tail(ch);
}
}
process(sender="S") {
s0:
while(TRUE) {
\* Send(m);
await Len(ch) < N;
with(m \in Msg)
ch := Append(ch, m);
}
}
process(receiver="R") {
r0:
while(TRUE) {
\* Recv();
await Len(ch) > 0;
ch := Tail(ch);
}
}
(*{
while(TRUE) {
either {
with(m \in Msg) {
Send(m);
}
}
or {
Recv();
}
}
}*)
}
*)
\* BEGIN TRANSLATION
VARIABLE ch
vars == << ch >>
ProcSet == {"S"} \cup {"R"}
Init == (* Global variables *)
/\ ch = <<>>
sender == /\ Len(ch) < N
/\ \E m \in Msg:
ch' = Append(ch, m)
receiver == /\ Len(ch) > 0
/\ ch' = Tail(ch)
Next == sender \/ receiver
Spec == Init /\ [][Next]_vars
\* END TRANSLATION
=============================================================================
\* Modification History
\* Last modified Tue Mar 24 14:39:27 CET 2015 by bela
\* Created Tue Mar 24 14:11:22 CET 2015 by bela