Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— 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, { P i } S i { Q i } { P 1 /\ …. /\ P n } co S 1 // …. // S n oc { Q 1 /\ …. /\ Q n }

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

5 Interference freedom Let a be 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 { P i } S i { Q i }, for all I, are interference free if –For all i for all assertions C in proof outline of S i, for all actions a in S j, i != j NI(a, C) holds

7 Concurrency rule { P i } S i { Q i } are interference free { P 1 /\ …. /\ P n } co S 1 // …. // S n oc { Q 1 /\ …. /\ Q n }

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 P i is of the form I /\ L, where L refers to local variables of P i or to variables that only P i writes. - Then the proof outlines will be interference free.

14 Concurrency rule for all i, { I} S i { I } { I } co S 1 // …. // S n { I}

15 Avoiding interference Synchronization


Download ppt "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."

Similar presentations


Ads by Google