Closed jthemphill closed 3 years ago
Thank you very much for the changes. A few more comments:
TypeOK == /\ forks \in [ 1..NP -> [holder : 1..NP, clean : BOOLEAN] ] /\ hungry \in [ 1..NP -> BOOLEAN ] /\ pc \in [ 1..NP -> {"Loop", "Eat", "Think"}]
ShareFork(p,q) == {LeftFork(p), RightFork(p)} \cap {LeftFork(q), RightFork(q)} # {} ExclusiveAccess == \A p,q \in 1..NP : p # q /\ ShareFork(p,q) => ~(pc[p] = "Eat" /\ pc[q] = "Eat")
If you agree, please make this changes and I'll merge the PR.
Best regards, Stephan
Thank you very much for your contribution! Merged into tlaplus/Examples.
I've been trying to learn TLA+ to suss out a rare bug in my code. On https://learntla.com/temporal-logic/operators/ , I came across a toy Dining Philosophers problem. It took me several hours to make everything work and build something free of deadlocks, livelocks, or starvation, so I'd like to add my knowledge to the bank.
This model solves the problem via Dijkstra's resource hierarchy solution. You should be able to run it with no changes via VSCode or the command-line, or with minimal changes via TLA toolbox.