You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.6 KiB
43 lines
1.6 KiB
// randomized dining philosophers [LR81]
|
|
// dxp/gxn 12/12/99
|
|
|
|
nondeterministic
|
|
|
|
// atomic formulae
|
|
// left fork free and right fork free resp.
|
|
formula lfree = p2=0..4,6,10;
|
|
formula rfree = p8=0..3,5,7,11;
|
|
|
|
module phil1
|
|
|
|
p1: [0..11];
|
|
|
|
[] p1=0 -> (p1'=0); // stay thinking
|
|
[] p1=0 -> (p1'=1); // trying
|
|
[] p1=1 -> 0.5 : (p1'=2) + 0.5 : (p1'=3); // draw randomly
|
|
[] p1=2 & lfree -> (p1'=4); // pick up left
|
|
[] p1=2 & !lfree -> (p1'=2); // left not free
|
|
[] p1=3 & rfree -> (p1'=5); // pick up right
|
|
[] p1=3 & !rfree -> (p1'=3); // right not free
|
|
[] p1=4 & rfree -> (p1'=8); // pick up right (got left)
|
|
[] p1=4 & !rfree -> (p1'=6); // right not free (got left)
|
|
[] p1=5 & lfree -> (p1'=8); // pick up left (got right)
|
|
[] p1=5 & !lfree -> (p1'=7); // left not free (got right)
|
|
[] p1=6 -> (p1'=1); // put down left
|
|
[] p1=7 -> (p1'=1); // put down right
|
|
[] p1=8 -> (p1'=9); // move to eating (got forks)
|
|
[] p1=9 -> (p1'=10); // finished eating and put down left
|
|
[] p1=9 -> (p1'=11); // finished eating and put down right
|
|
[] p1=10 -> (p1'=0); // put down right and return to think
|
|
[] p1=11 -> (p1'=0); // put down left and return to think
|
|
|
|
endmodule
|
|
|
|
// construct further modules through renaming
|
|
module phil2 = phil1 [p1=p2, p2=p3, p8=p1] endmodule
|
|
module phil3 = phil1 [p1=p3, p2=p4, p8=p2] endmodule
|
|
module phil4 = phil1 [p1=p4, p2=p5, p8=p3] endmodule
|
|
module phil5 = phil1 [p1=p5, p2=p6, p8=p4] endmodule
|
|
module phil6 = phil1 [p1=p6, p2=p7, p8=p5] endmodule
|
|
module phil7 = phil1 [p1=p7, p2=p8, p8=p6] endmodule
|
|
module phil8 = phil1 [p1=p8, p2=p1, p8=p7] endmodule
|