Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Peterson's algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Mutual exclusion === {{Main|Mutual exclusion}} P0 and P1 can never be in the critical section at the same time. If P0 is in its critical section, then <code>flag[0]</code> is true. In addition, either <code>flag[1]</code> is <code>false</code> (meaning that P1 has left its critical section), or <code>turn</code> is <code>0</code> (meaning that P1 is just now trying to enter the critical section, but graciously waiting), or P1 is at label <code>P1_gate</code> (trying to enter its critical section, after setting <code>flag[1]</code> to <code>true</code> but before setting <code>turn</code> to <code>0</code> and busy waiting). So if both processes are in their critical sections, then we conclude that the state must satisfy <code>flag[0]</code> and <code>flag[1]</code> and <code>turn = 0</code> and <code>turn = 1</code>. No state can satisfy both <code>turn = 0</code> and <code>turn = 1</code>, so there can be no state where both processes are in their critical sections. (This recounts an argument that is made rigorous in Schneider 1997.<ref name="Schneider.p185">F. B. Schneider, ''On Concurrent Programming'', Springer Verlag, 1997, pages 185β196.</ref>)
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)