Verification of Dekkers Algorithm Proof of mutual exclusion - - PowerPoint PPT Presentation

verification of dekker s algorithm proof of mutual
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CoSc 450: Programming Paradigms

Verification of Dekker’s Algorithm

04

slide-2
SLIDE 2

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

slide-3
SLIDE 3

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

slide-4
SLIDE 4

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.

slide-5
SLIDE 5

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

slide-6
SLIDE 6

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

slide-7
SLIDE 7
  • (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

slide-8
SLIDE 8
  • (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

slide-9
SLIDE 9
  • (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

slide-10
SLIDE 10
  • (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

slide-11
SLIDE 11
  • (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

slide-12
SLIDE 12
  • (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

slide-13
SLIDE 13
  • (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

slide-14
SLIDE 14
  • 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

slide-15
SLIDE 15
  • 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

slide-16
SLIDE 16
  • 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

slide-17
SLIDE 17
  • 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

slide-18
SLIDE 18
  • 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

slide-19
SLIDE 19
  • 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

slide-20
SLIDE 20
  • 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

slide-21
SLIDE 21
  • 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

slide-22
SLIDE 22
  • 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

slide-23
SLIDE 23
  • 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

slide-24
SLIDE 24
  • 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

slide-25
SLIDE 25
  • 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

slide-26
SLIDE 26
  • 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

slide-27
SLIDE 27
  • 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

slide-28
SLIDE 28
  • 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

slide-29
SLIDE 29

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
slide-30
SLIDE 30

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
slide-31
SLIDE 31
  • ¬(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
slide-32
SLIDE 32
  • ¬(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
slide-33
SLIDE 33
  • ¬(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
slide-34
SLIDE 34
  • ¬(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
slide-35
SLIDE 35
  • ¬(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
slide-36
SLIDE 36
  • ¬(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
slide-37
SLIDE 37
  • ¬(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
slide-38
SLIDE 38

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

slide-39
SLIDE 39

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

slide-40
SLIDE 40

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

slide-41
SLIDE 41

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

slide-42
SLIDE 42

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

slide-43
SLIDE 43

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

slide-44
SLIDE 44

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

slide-45
SLIDE 45

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

slide-46
SLIDE 46

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
slide-47
SLIDE 47

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

slide-48
SLIDE 48

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

slide-49
SLIDE 49

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

slide-50
SLIDE 50

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

slide-51
SLIDE 51

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

slide-52
SLIDE 52

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

slide-53
SLIDE 53

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

slide-54
SLIDE 54

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 ⟩

slide-55
SLIDE 55

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 ⟩

slide-56
SLIDE 56

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 ⟩

slide-57
SLIDE 57

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 ⟩

slide-58
SLIDE 58

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 ⟩

slide-59
SLIDE 59

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

slide-60
SLIDE 60

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

slide-61
SLIDE 61

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

slide-62
SLIDE 62

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

slide-63
SLIDE 63

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

slide-64
SLIDE 64

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

slide-65
SLIDE 65

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

slide-66
SLIDE 66

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

slide-67
SLIDE 67

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

slide-68
SLIDE 68

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

slide-69
SLIDE 69

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

slide-70
SLIDE 70

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

slide-71
SLIDE 71

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

slide-72
SLIDE 72

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

slide-73
SLIDE 73

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

slide-74
SLIDE 74

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

slide-75
SLIDE 75

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

slide-76
SLIDE 76

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

slide-77
SLIDE 77

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

slide-78
SLIDE 78

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

slide-79
SLIDE 79

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

slide-80
SLIDE 80

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

slide-81
SLIDE 81

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

slide-82
SLIDE 82

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