-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.m
44 lines (39 loc) · 864 Bytes
/
server.m
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
type server_t : 0..1;
var lock : boolean;
var clients : array[server_t] of boolean;
ruleset idx : server_t do
alias self : clients[idx]; other : clients[1 - idx] do
rule "get connection"
!self & !lock
==>
begin
lock := true;
self := true;
end;
rule "keep connection"
self
==>
begin
end;
rule "release connection"
self
==>
begin
self := false;
lock := false;
end;
end;
endruleset;
startstate
lock := false;
for idx : server_t do
clients[idx] := false;
end;
end;
invariant "only one connection"
forall idx : server_t do
clients[idx] = true ->
forall jdx : server_t do
clients[jdx] = true -> idx = jdx
end
end;