46 lines
1.1 KiB
Text
46 lines
1.1 KiB
Text
MODULE main
|
|
VAR
|
|
wp : boolean;
|
|
wq : boolean;
|
|
p : process user(wp,wq);
|
|
q : process user(wq,wp);
|
|
ASSIGN
|
|
init(wp) := FALSE;
|
|
init(wq) := FALSE;
|
|
|
|
SPEC -- PROGRESS
|
|
AG (p.state = local -> EF p.state = enter )
|
|
SPEC -- MUTUAL EXCLUSION
|
|
AG !(p.state = critical & q.state = critical)
|
|
SPEC -- DEADLOCK
|
|
AG (p.state = set -> AF (p.state = critical | q.state = critical))
|
|
SPEC -- INDIVIDUAL STARVATION
|
|
AG (p.state = set -> AF p.state = critical)
|
|
|
|
MODULE user(wp, wq)
|
|
VAR
|
|
state : {local,set,enter,loopUnset, loopSet, critical, exit};
|
|
ASSIGN
|
|
init(state) := local;
|
|
next(state) :=
|
|
case
|
|
state = local : {local, set};
|
|
state = set : enter;
|
|
state = enter & wq = FALSE : critical;
|
|
state = enter & wq = TRUE : loopUnset;
|
|
state = loopUnset : loopSet;
|
|
state = loopSet : enter;
|
|
state = critical : exit;
|
|
state = exit : local;
|
|
TRUE : state;
|
|
esac;
|
|
next(wp) :=
|
|
case
|
|
state = set : TRUE;
|
|
state = loopUnset : FALSE;
|
|
state = loopSet : TRUE;
|
|
state = exit : FALSE;
|
|
TRUE : wp;
|
|
esac;
|
|
FAIRNESS
|
|
running
|