Verification of Dekkers Algorithm Proof of mutual exclusion - - PowerPoint PPT Presentation
Verification of Dekkers Algorithm Proof of mutual exclusion - - PowerPoint PPT Presentation
CoSc 450: Programming Paradigms 04 Verification of Dekkers Algorithm Proof of mutual exclusion Algorithm 4.2: Dekkers algorithm boolean wantp false, wantq false integer turn 1 p q loop forever loop forever non-critical
Algorithm 4.2: Dekker’s algorithm boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q loop forever loop forever
p1:
non-critical section
q1:
non-critical section
p2:
wantp ¿ true
q2:
wantq ¿ true
p3:
while wantq
q3:
while wantp
p4:
if turn = 2
q4:
if turn = 1
p5:
wantp ¿ false
q5:
wantq ¿ false
p6:
await turn = 1
q6:
await turn = 2
p7:
wantp ¿ true
q7:
wantq ¿ true
p8:
critical section
q8:
critical section
p9:
turn ¿ 2
q9:
turn ¿ 1
p10:
wantp ¿ false
q10:
wantq ¿ false
Proof of mutual exclusion
Algorithm 4.2: Dekker’s algorithm boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q loop forever loop forever
p1:
non-critical section
q1:
non-critical section
p2:
wantp ¿ true
q2:
wantq ¿ true
p3:
while wantq
q3:
while wantp
p4:
if turn = 2
q4:
if turn = 1
p5:
wantp ¿ false
q5:
wantq ¿ false
p6:
await turn = 1
q6:
await turn = 2
p7:
wantp ¿ true
q7:
wantq ¿ true
p8:
critical section
q8:
critical section
p9:
turn ¿ 2
q9:
turn ¿ 1
p10:
wantp ¿ false
q10:
wantq ¿ false
Proof of mutual exclusion
Lemma 4.10
- turn = 1∨turn = 2
p3..5∨ p8..10 ≡ wantp q3..5∨q8..10 ≡ wantq
Algorithm 4.2: Dekker’s algorithm boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q loop forever loop forever
p1:
non-critical section
q1:
non-critical section
p2:
wantp ¿ true
q2:
wantq ¿ true
p3:
while wantq
q3:
while wantp
p4:
if turn = 2
q4:
if turn = 1
p5:
wantp ¿ false
q5:
wantq ¿ false
p6:
await turn = 1
q6:
await turn = 2
p7:
wantp ¿ true
q7:
wantq ¿ true
p8:
critical section
q8:
critical section
p9:
turn ¿ 2
q9:
turn ¿ 1
p10:
wantp ¿ false
q10:
wantq ¿ false
Proof of mutual exclusion
Lemma 4.10
- turn = 1∨turn = 2
p3..5∨ p8..10 ≡ wantp q3..5∨q8..10 ≡ wantq
- It is an exercise for the student to
prove these lemmas and to use them to prove that Dekker’s algorithm satisfies mutual exclusion.
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- (p8 ⇒ p9)
q1 ⇒ q2 ¬q1 q1 p4∧(turn = 2) ⇒ p5 p4∧(turn = 2) ⇒ p5 p4∧¬(turn = 2) ⇒ p3 q A∧(A ⇒ B) ⇒ B p,q := q, p
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q1
⇒ ⟨ q1 ⇒ q2⟩ q2 ⇒ ⟨ ⟩ q3 ⇒ ⟨ wantp⟩ q4 ⇒ ⟨ turn = 1⟩ q5 ⇒ ⟨ ⟩ q6 ⇒ ⟨ turn = 1⟩ q6
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q6
⇒ ⟨ q3...5 q8..10⟩ ¬(q3...5∨q8..10) ⇒ ⟨ q3..5∨q8..10 ≡ wantq⟩ ¬wantq
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q6
⇒ ⟨ q3...5 q8..10⟩ ¬(q3...5∨q8..10) ⇒ ⟨ q3..5∨q8..10 ≡ wantq⟩ ¬wantq
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q6
⇒ ⟨ q3...5 q8..10⟩ ¬(q3...5∨q8..10) ⇒ ⟨ q3..5∨q8..10 ≡ wantq⟩ ¬wantq
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q6
⇒ ⟨ q3...5 q8..10⟩ ¬(q3...5∨q8..10) ⇒ ⟨ q3..5∨q8..10 ≡ wantq⟩ ¬wantq
- p q
wantp∧turn = 1 ⇒ ¬wantq
- Proof of starvation-free
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
- q6
⇒ ⟨ q3...5 q8..10⟩ ¬(q3...5∨q8..10) ⇒ ⟨ q3..5∨q8..10 ≡ wantq⟩ ¬wantq
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- ¬(p2 ⇒ p8)
- ⟨ p ⇒ q ≡ ¬p∨q⟩
¬(¬p2∨ p8)
- ⟨⟩
p2∧¬ p8 ⇒ ⟨ p2∧¬ p8 ⇒ p3, p4 ⟩ p3, p4
- loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p p2 ⇒ p8
- p3, p4
- ⟨ p3..5∨ p8..10 ≡ wantp
⟩ wantp∧turn = 1 ⇒ ⟨ wantp∧turn = 1 ⇒ ¬wantq⟩ ¬wantq ⇒ ⟨ ⟩ ¬(p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨ p2∧¬ p8 ⇒ ¬turn = 2⟩ ¬turn = 2
- ⟨ ¬ p ≡ ¬p⟩
¬turn = 2 ⇒ ⟨ turn = 1∨turn = 2⟩ turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨p9 p8⟩ p9 ⇒ ⟨ p9 ⟩
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨p9 p8⟩ p9 ⇒ ⟨ p9 ⟩
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨p9 p8⟩ p9 ⇒ ⟨ p9 ⟩
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨p9 p8⟩ p9 ⇒ ⟨ p9 ⟩
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8
⇒ ⟨p9 p8⟩ p9 ⇒ ⟨ p9 ⟩
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8 ⇒ turn = 1
p2∧¬ p8 ⇒ turn = 1 p p8 p3, p4 turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8 ⇒ turn = 1
p2∧¬ p8 ⇒ turn = 1 p p8 p3, p4 turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8 ⇒ turn = 1
p2∧¬ p8 ⇒ turn = 1 p p8 p3, p4 turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ p3, p4
- p2∧¬ p8 ⇒ turn = 1
p2∧¬ p8 ⇒ turn = 1 p p8 p3, p4 turn = 1
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
p1:
non-critical section
p2:
wantp ¿ true
p3:
while wantq
p4:
if turn = 2
p5:
wantp ¿ false
p6:
await turn = 1
p7:
wantp ¿ true
p8:
critical section
p9:
turn ¿ 2
p10:
wantp ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2
loop forever
q1:
non-critical section
q2:
wantq ¿ true
q3:
while wantp
q4:
if turn = 1
q5:
wantq ¿ false
q6:
await turn = 2
q7:
wantq ¿ true
q8:
critical section
q9:
turn ¿ 1
q10:
wantq ¿ false
Proof of starvation-free
- p2∧¬ p8 ⇒ ¬turn = 2
turn = 2 ⇒ ⟨ ⟩ p6 ⇒ ⟨ p3..5∨ p8..10 ≡ wantp⟩ ¬wantp ⇒ ⟨ ⟩ q9 ⇒ ⟨ ← ⟩ turn = 1 turn = 2