1 / 15

CIS 720

CIS 720. Correctness of Concurrent Programs. i := 1 max := A[1] do i < n  i = i + 1 if (max < A[i]) max = A[i] od. Concurrency rule.

loring
Download Presentation

CIS 720

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 720 Correctness of Concurrent Programs

  2. i := 1 max := A[1] do i < n  i = i + 1 if (max < A[i]) max = A[i] od

  3. Concurrency rule for all i, { Pi } Si { Qi } { P1 /\ …. /\ Pn} co S1 // …. // Snoc { Q1 /\ …. /\ Qn}

  4. x = 0; y = 1; x = 0; co co x = 1 x = x + 1 // // y = y + 1 x = x + 2 oc oc

  5. Interference freedom • Let abe a statement and C be an assertion. • NI(a, C) iff { pre(a) /\ C } a { C } • Execution of a does not invalidates (or interferes) with C.

  6. { Pi } Si { Qi }, for all I, are interference free if • For all i for all assertions C in proof outline of Si, for all actions a in Sj, i != j NI(a, C) holds

  7. Concurrency rule { Pi } Si { Qi } are interference free { P1 /\ …. /\ Pn} co S1 // …. // Snoc { Q1 /\ …. /\ Qn}

  8. x= 0; co x = x + 1 // x = x + 2 od

  9. Bank transactions co // Transfer(x,y,am): Auditor: ac[x] = ac[x] – am; total = 0; i = 0; ac[y] = ac[y] + am do i < n total = total + ac[i] i = i + 1 od oc

  10. Bank transactions co // Transfer(x,y,am): Auditor: if < !auditon  ac[x] = ac[x] – am; auditon = 1; total = 0; i = 0; ac[y] = ac[y] + am > [] do i < n <auditon && ( (x < i && y < i) ||(x > I && y > i)) total = total + ac[i]  ac[x] = ac[x] – am; ac[y] = ac[y] + am> i = i + 1 fi od auditon = 0 oc

  11. Techniques to avoid interference • Disjoint variables • If the write set of each process is disjoint from the read and write set of other processes, then the proof outlines will be interference free.

  12. Avoiding interference • Weakened assertions x= 0; co x = x + 1 // x = x + 2 od

  13. Avoiding interference • Global Invariants: Assume that every assertion in the proof outline of Pi is of the form I /\ L, where L refers to local variables of Pi or to variables that only Pi writes. - Then the proof outlines will be interference free.

  14. Concurrency rule for all i, { I} Si { I } { I} co S1 // …. // Sn { I}

  15. Avoiding interference • Synchronization

More Related