Last active
December 13, 2015 18:38
-
-
Save Hydrotoast/4956492 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
# No progress | |
def algo1(): | |
while turn != i: | |
# no-op | |
# crit section | |
turn = j | |
# remainder section | |
# No progress | |
def algo2(): | |
flag[i] = true | |
while flag[j]: | |
# no-op | |
# crit section | |
flag[i] = false | |
# remainder section | |
# No mutual exclusion | |
def algo3(): | |
while flag[j]: | |
# no-op | |
flag[i] = true | |
#crit section | |
flag[i] = false | |
# remainder section | |
# Satisfies all criteria | |
def peters_algo(): | |
flag[i] = true | |
turn = j | |
while flag[j] && turn == j: | |
# no-op | |
# crit section | |
flag[i] = false | |
# remainder section | |
def bakers_algo(): | |
choosing[i] = true | |
number[i] = max(numbers) + 1 | |
choosing[i] = false | |
for j in range(len(numbers)): | |
while choosing[j]: | |
# no-op | |
while number[j] != 0 && number[j] < number[i]: | |
# no-op | |
# crit section | |
number[i] = 0 | |
# remainder section |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment