-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpeterson_two_proc.cub
85 lines (62 loc) · 1.72 KB
/
peterson_two_proc.cub
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
number_procs 2
type loc = L1 | L2 | Wait | Crit | L3
array PC[proc] : loc
array Want[proc] : bool
var Turn : proc
init () { PC[#1] = L1 && PC[#2] = L1 &&
Want[#1] = False && Want[#2] = False }
unsafe (z) { PC[#1] = Crit && PC[#2] = Crit }
(* proc 1 *)
transition req_P1 ()
requires { PC[#1] = L1 }
{
Want[j] := case | j = #1 : True | _ : Want[j];
PC[j] := case | j = #1 : L2 | _ : PC[j] }
transition myturn_P1 ()
requires { PC[#1] = L2 }
{
Turn := #1;
PC[j] := case | j = #1 : Wait | _ : PC[j] }
transition enter1_P1 ()
requires { PC[#1] = Wait && Want[#2] = False }
{ PC[j] := case | j = #1 : Crit | _ : PC[j] }
transition enter2_P1 ()
requires { PC[#1] = Wait && Turn = #2 }
{ PC[j] := case | j = #1 : Crit | _ : PC[j] }
transition exit_P1 ()
requires { PC[#1] = Crit }
{
PC[j] := case | j = #1 : L3 | _ : PC[j] }
transition not_want_P1 ()
requires { PC[#1] = L3 }
{
Want[j] := case | j = #1 : False | _ : Want[j];
PC[j] := case | j = #1 : L1 | _ : PC[j]
}
(* proc 2 *)
transition req_P2 ()
requires { PC[#2] = L1 }
{
Want[j] := case | j = #2 : True | _ : Want[j];
PC[j] := case | j = #2 : L2 | _ : PC[j] }
transition myturn_P2 ()
requires { PC[#2] = L2 }
{
Turn := #2;
PC[j] := case | j = #2 : Wait | _ : PC[j] }
transition enter1_P2 ()
requires { PC[#2] = Wait && Want[#1] = False }
{ PC[j] := case | j = #2 : Crit | _ : PC[j] }
transition enter2_P2 ()
requires { PC[#2] = Wait && Turn = #1 }
{ PC[j] := case | j = #2 : Crit | _ : PC[j] }
transition exit_P2 ()
requires { PC[#2] = Crit }
{
PC[j] := case | j = #2 : L3 | _ : PC[j] }
transition not_want_P2 ()
requires { PC[#2] = L3 }
{
Want[j] := case | j = #2 : False | _ : Want[j];
PC[j] := case | j = #2 : L1 | _ : PC[j]
}