what i teach (do what i say, not what i do)
Post on 08-Jan-2016
38 Views
Preview:
DESCRIPTION
TRANSCRIPT
What I Teach(Do what I say, not what I do)
Andrew LumsdaineIndiana University
B524: Parallelism in Programming Languages and Systems
Andrew LumsdaineComputer Science Department
Indiana UniversityBloomington, IN 47401
Course Text
• Andrews, “Foundations of Multithreaded, Parallel, and Distributed Programming”
Supplemental Text
• Schneider, “On Concurrent Programming”
Supplemental Texts
• Andrews, Concurrent Programming
Course Outline
• Introduction / overview• Program logic• Semantics of concurrency• Safety properties• Fine grained atomicity• Semaphores, locks, etc• Message passing• Case studies
Semantics of Concurrent Execution
• Await Rule
• Co Rule
{P Λ B} S {Q}
{P} < await (B) S;> {Q}
{Pi} Si {Qi} are interference free
{P1 Λ P2 Λ … Pn}Co S1 ; // S2 … // Sn; oc{Q1 Λ Q2 Λ … Qn}
Critical Section Problemsem mutex = 1;
process CS[i = 1 to n] { while (true) { P(mutex); critical section; V(mutex); noncritical section; }}
Correctness?
sem mx = 1;
process CS[i = 1 to n] { while (true) { P(mx); critical section; V(mx); noncritical section; }}
€
I :mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
Is {I} preserved by P(mx)?
Correctness
€
{V = ( : in(CS j )j≠ i∑ ∨after(CS j ) :1)}
entry i
{V = ( : in(CS j )j≠ i∑ ∨after(CS j ) :1)}
€
{¬(in(CSi)∨after(CSi))}
entry i{in(CSi)}
Correctness
€
{V = ( : in(CS j )j∑ ∨after(CS j ) :1)}
entry i
{V +1= ( : in(CS j )j∑ ∨after(CS j ) :1)}
Correctness
€
{mx > 0⇒ (mx −1=1− (V +1)}
entry i{mx =1= (V +1)}
€
(mx −1=1− (V +1))⇒ (mx > 0⇒ (mx −1=1− (V +1)))
€
{mx −1=1− (V +1)}
entry i{mx =1− (V +1)}
Correctness
€
mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
∧V = ( : in(CS j )j∑ ∨after(CS j ) :1)
⇒ mx −1=1− (V +1)∧V = ( : in(CS j )j∑ ∨after(CS j ) :1)
€
mx =1− (V +1)∧V +1= ( : in(CS j )j∑ ∨after(CS j ) :1)
⇒ mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
Correctness
€
mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
∧V = ( : in(CS j )j∑ ∨after(CS j ) :1)
entry i
mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
€
mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
entry i
mx =1− ( : in(CS j )j∑ ∨after(CS j ) :1)
top related