verification of dekker s algorithm proof of mutual
play

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


  1. CoSc 450: Programming Paradigms 04 Verification of Dekker’s Algorithm

  2. Proof of mutual exclusion Algorithm 4.2: Dekker’s algorithm boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q loop forever loop forever non-critical section non-critical section p1: q1: wantp ¿ true wantq ¿ true p2: q2: while wantq while wantp p3: q3: if turn = 2 if turn = 1 p4: q4: wantp ¿ false wantq ¿ false p5: q5: await turn = 1 await turn = 2 p6: q6: wantp ¿ true wantq ¿ true p7: q7: critical section critical section p8: q8: turn ¿ 2 turn ¿ 1 p9: q9: wantp ¿ false wantq ¿ false p10: q10:

  3. �������������� ��������� ��������������������� ���� � �������� ��������������� ���������� Proof of mutual exclusion Algorithm 4.2: Dekker’s algorithm � ������������������ boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q ���������������������� loop forever loop forever non-critical section non-critical section p1: q1: wantp ¿ true wantq ¿ true p2: q2: ������ while wantq while wantp p3: q3: if turn = 2 if turn = 1 p4: q4: wantp ¿ false wantq ¿ false p5: q5: await turn = 1 await turn = 2 p6: q6: wantp ¿ true wantq ¿ true p7: q7: ���� ����������� critical section critical section p8: q8: turn ¿ 2 turn ¿ 1 p9: q9: ����������� ������������ wantp ¿ false wantq ¿ false p10: q10: ������������������������������������������� Lemma 4.10 ����� turn = 1 ∨ turn = 2 ����� p 3 .. 5 ∨ p 8 .. 10 ≡ wantp ����� q 3 .. 5 ∨ q 8 .. 10 ≡ wantq �

  4. �������������� ��������� ��������������������� ���� � �������� ��������������� ���������� Proof of mutual exclusion Algorithm 4.2: Dekker’s algorithm � ������������������ boolean wantp ¿ false, wantq ¿ false integer turn ¿ 1 p q ���������������������� loop forever loop forever non-critical section non-critical section p1: q1: wantp ¿ true wantq ¿ true p2: q2: ������ while wantq while wantp p3: q3: if turn = 2 if turn = 1 p4: q4: wantp ¿ false wantq ¿ false p5: q5: await turn = 1 await turn = 2 p6: q6: wantp ¿ true wantq ¿ true p7: q7: ���� ����������� critical section critical section p8: q8: turn ¿ 2 turn ¿ 1 p9: q9: ����������� ������������ wantp ¿ false wantq ¿ false p10: q10: ������������������������������������������� Lemma 4.10 It is an exercise for the student to prove these lemmas and to use ����� turn = 1 ∨ turn = 2 them to prove that Dekker’s ����� p 3 .. 5 ∨ p 8 .. 10 ≡ wantp algorithm satisfies mutual exclusion. ����� q 3 .. 5 ∨ q 8 .. 10 ≡ wantq �

  5. �������������� ��������� ��������������������� ���� � �������� ��������������� ���������� � ������������������ ���������������������� ������ ���� ����������� ����������� ������������ ������������������������������������������� ����� ����� ����� Proof of starvation-free ������������ loop forever �� ����������������������������������� non-critical section p1: wantp ¿ true p2: �� � ( p 8 ⇒ � p 9 ) while wantq p3: �� q 1 ⇒ � q 2 if turn = 2 p4: wantp ¿ false p5: ������������������������� �� ¬ q 1 await turn = 1 p6: � �� q 1 � �������������������������� wantp ¿ true p7: critical section �� p 4 ∧ � ( turn = 2 ) ⇒ � p 5 p8: turn ¿ 2 p9: ����� �������������������������������� wantp ¿ false p10: p 4 ∧ ( turn = 2 ) ⇒ � p 5 p 4 ∧ ¬ ( turn = 2 ) ⇒ � p 3 ������������������������������������������������� �� q � �� ������������������������ �� A ∧ ( � A ⇒ � B ) ⇒ � B �� ��������������������������������� ����������������� p , q : = q , p � �

  6. �������������� ��������� ��������������������� ���� � �������� ��������������� ���������� � ������������������ ���������������������� ������ ���� ����������� ����������� ������������ ������������������������������������������� ����� ����� ����� Proof of starvation-free ������������ loop forever �� ����������������������������������� non-critical section p1: wantp ¿ true p2: �� � ( p 8 ⇒ � p 9 ) while wantq p3: �� q 1 ⇒ � q 2 if turn = 2 p4: wantp ¿ false p5: ������������������������� �� ¬ q 1 await turn = 1 p6: � �� q 1 � �������������������������� wantp ¿ true p7: critical section �� p 4 ∧ � ( turn = 2 ) ⇒ � p 5 p8: turn ¿ 2 p9: ����� �������������������������������� wantp ¿ false p10: p 4 ∧ ( turn = 2 ) ⇒ � p 5 p 4 ∧ ¬ ( turn = 2 ) ⇒ � p 3 ������������������������������������������������� �� q � �� ������������������������ �� A ∧ ( � A ⇒ � B ) ⇒ � B �� ��������������������������������� ����������������� p , q : = q , p � �

  7. �������������� ��������� ��������������������� ���� � �������� ��������������� ���������� � ������������������ ���������������������� ������ ���� ����������� ����������� ������������ ������������������������������������������� ����� ����� ����� Proof of starvation-free ������������ loop forever �� ����������������������������������� non-critical section p1: wantp ¿ true p2: �� � ( p 8 ⇒ � p 9 ) while wantq p3: �� q 1 ⇒ � q 2 if turn = 2 p4: wantp ¿ false p5: ������������������������� �� ¬ q 1 await turn = 1 p6: � �� q 1 � �������������������������� wantp ¿ true p7: critical section �� p 4 ∧ � ( turn = 2 ) ⇒ � p 5 p8: turn ¿ 2 p9: ����� �������������������������������� wantp ¿ false p10: p 4 ∧ ( turn = 2 ) ⇒ � p 5 p 4 ∧ ¬ ( turn = 2 ) ⇒ � p 3 ������������������������������������������������� �� q � �� ������������������������ �� A ∧ ( � A ⇒ � B ) ⇒ � B �� ��������������������������������� ����������������� p , q : = q , p � �

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend