Created
October 24, 2020 13:30
-
-
Save yqthu/5812da7494fd557446218c24dbd0d2ec to your computer and use it in GitHub Desktop.
Peterson's algorithm is not starvation-free?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MODULE Process (other_flag, turn) | |
| VAR | |
| pc : {idle, request, critical, release}; | |
| flag : boolean; | |
| ASSIGN | |
| init (pc) := idle; | |
| next (pc) := | |
| case | |
| pc = idle : {idle, request}; | |
| pc = request & other_flag & turn : request; | |
| pc = request & (!other_flag | !turn) : {request, critical}; | |
| pc = critical : {critical, release}; | |
| pc = release : {release, idle}; | |
| esac; | |
| init (flag) := FALSE; | |
| next (flag) := | |
| case | |
| pc = idle & next(pc) = request : TRUE; | |
| pc = release & next(pc) = idle : FALSE; | |
| TRUE: flag; | |
| esac; | |
| MODULE main | |
| VAR | |
| turn : boolean; | |
| alice : Process(bob.flag, turn); | |
| bob: Process(alice.flag, !turn); | |
| ASSIGN | |
| next (turn) := | |
| case | |
| alice.pc = idle & next(alice.pc) = request : TRUE; | |
| bob.pc = idle & next(bob.pc) = request : FALSE; | |
| TRUE : turn; | |
| esac; | |
| SPEC AG !(alice.pc = critical & bob.pc = critical); -- Mutual exclusion | |
| SPEC AG (alice.pc = request -> EF alice.pc = critical); -- Deadlock-free, No LTL equivalent | |
| SPEC AG (bob.pc = request -> EF bob.pc = critical); -- Deadlock-free | |
| LTLSPEC G F alice.pc = request -> F alice.pc = critical; -- No starvation, Why is this FALSE? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment