36 lines
855 B
Text
36 lines
855 B
Text
MODULE main
|
|
VAR
|
|
turn : 1..2;
|
|
p : process user(turn, 1, 2);
|
|
q : process user(turn, 2, 1);
|
|
ASSIGN
|
|
init(turn) := 1;
|
|
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 = enter -> AF (p.state = critical | q.state = critical))
|
|
SPEC -- INDIVIDUAL STARVATION
|
|
AG (p.state = enter -> AF p.state = critical)
|
|
|
|
MODULE user(turnloc, myproc, otherproc)
|
|
VAR
|
|
state : {local,enter,critical,exit};
|
|
ASSIGN
|
|
init(state) := local;
|
|
next(state) :=
|
|
case
|
|
state = local : {local, enter};
|
|
state = enter & turnloc = myproc : critical;
|
|
state = critical : exit;
|
|
state = exit : local;
|
|
TRUE : state;
|
|
esac;
|
|
next(turnloc) :=
|
|
case
|
|
state = exit : otherproc;
|
|
TRUE : turnloc;
|
|
esac;
|
|
FAIRNESS
|
|
running
|