-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMESI.m
More file actions
55 lines (42 loc) · 949 Bytes
/
MESI.m
File metadata and controls
55 lines (42 loc) · 949 Bytes
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
const clientNUMS : 3;
type location: enum{ M, E, S, I};
client: 1 .. clientNUMS;
var state : array [client] of location;
ruleset i : client do
rule "t1" state[i] = E ==>
begin
state[i] := M; endrule;
rule "t2"
state[i] = I ==>
begin
for j: client do
if (j=i) then state[j]:=S;
elsif (state[j]=E) then state[j]:=S;
elsif (state[j]=M) then state[j]:=S;
elsif (state[j]=I) then state[j]:=I;
else state[j]:=S;
endif;
endfor; endrule;
rule "t3"
state[i] = S ==>
begin
for j: client do
if (j=i) then state[j]:=E ;
else state[j]:=I;
endif;
endfor; endrule;
rule "t4"
state[i] = I ==>
begin
for j: client do
if (j=i) then state[j]:=E ;
else state[j]:=I;
endif;
endfor; endrule;
endruleset;
startstate
begin
for i: client do
state[i] := I;
endfor;
endstartstate;