-
-
-
CENAPAD-MGCO
A seguir: Proof of Mutual Exclusion
Acima: O Algoritmo de Naimi-Trehel
Anterior: Auxiliary Variables
Rule 1: getting hungry
s = thinking
![]()
s := hungry
Rule 2: starting to eat
s = hungry, Hastoken
![]()
s := eating
Rule 3: stoping to eat, keeping the token
s = eating, ReqList =
![]()
![]()
s := thinking
Rule 4: stoping to eat, sending the token
s = eating,
ReqList
EMPTY![]()
s:= thinking ;
Next := last(ReqList);
T.ReqList := tail(ReqList);
send(head(ReqList), T); HasToken := FALSE;
ReqList := EMPTY;
for all k
T.ReqList do
[k]:=
[k] cat Myself;Rule 5: requesting the token
s = hungry, Next
nil![]()
send(Next, Request(Myself));
Next := nil;
[Myself] := EMPTY;Rule 6: storing a request
Receive(R), s
thinking![]()
put(ReqList, R.origin)
Rule 7: releasing the token
Receive(R), s = thinking, Next = nil
![]()
T.ReqList := EMPTY;
send(R.origin, T);
HasToken := FALSE;
Next := R.origin
Rule 8: forwarding a request
Receive(R), s = thinking,
Next
nil![]()
send(Next, R);
Next := R.origin;
[R.origin] :=
[R.origin] cat Myself;Rule 9: receiving the token
Receive(T)
![]()
Hastoken := TRUE;
ReqList := T.ReqList cat ReqList
[Myself] := EMPTY;