Last active
January 29, 2025 04:38
-
-
Save aerodame/530368bfda45965e1f4b70de8b620f41 to your computer and use it in GitHub Desktop.
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
| // j = 1-i ; i=0, j=1 | |
| // Process Pi | |
| Pi() { | |
| flag[i] = true; | |
| turn = j; | |
| // entry section | |
| while (flag[j] && turn == j); // Busy wait | |
| // Critical Section | |
| // exit section | |
| flag[i] = false; | |
| } | |
| // j = 1-i ; i=0, j=1 | |
| // Process Pj | |
| Pj() { | |
| flag[j] = true; | |
| turn = i; | |
| while (flag[i] && turn == i); // Busy wait | |
| // Critical Section | |
| flag[j] = false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment