For Dekker's algorithm given below (from Wikipedia), why is it that we wait for the turn to change, instead of waiting for p1 to set it's flag to false? It seems to me that it would be safer (or more efficient?) to wait for p1 to complete its exit routine before p0 sets its intent again. It seems like a livelock isn't an issue since we still check for turn on line 3, so when both processes declare their intent, then there is a tie breaker.
p0:
0 while(true) {
1 wants_to_enter[0] ← true
2 while (wants_to_enter[1]) {
3 if (turn ≠ 0) {
4 wants_to_enter[0] ← false
5 while (turn ≠ 0) {} // change this to while (wants_to_enter[1])
6 wants_to_enter[0] ← true
7 }
8 }
9 ...
10 // critical section
11 ...
12 turn ← 1
13 wants_to_enter[0] ← false
14 }