17
What I Teach (Do what I say, not what I do) Andrew Lumsdaine Indiana University

What I Teach (Do what I say, not what I do)

  • Upload
    landon

  • View
    38

  • Download
    2

Embed Size (px)

DESCRIPTION

What I Teach (Do what I say, not what I do). Andrew Lumsdaine Indiana University. B524: Parallelism in Programming Languages and Systems. Andrew Lumsdaine Computer Science Department Indiana University Bloomington, IN 47401. Course Text. - PowerPoint PPT Presentation

Citation preview

Page 1: What I Teach (Do what I say, not what I do)

What I Teach(Do what I say, not what I do)

Andrew LumsdaineIndiana University

Page 2: What I Teach (Do what I say, not what I do)
Page 3: What I Teach (Do what I say, not what I do)

B524: Parallelism in Programming Languages and Systems

Andrew LumsdaineComputer Science Department

Indiana UniversityBloomington, IN 47401

Page 4: What I Teach (Do what I say, not what I do)

Course Text

• Andrews, “Foundations of Multithreaded, Parallel, and Distributed Programming”

Page 5: What I Teach (Do what I say, not what I do)

Supplemental Text

• Schneider, “On Concurrent Programming”

Page 6: What I Teach (Do what I say, not what I do)

Supplemental Texts

• Andrews, Concurrent Programming

Page 7: What I Teach (Do what I say, not what I do)
Page 8: What I Teach (Do what I say, not what I do)

Course Outline

• Introduction / overview• Program logic• Semantics of concurrency• Safety properties• Fine grained atomicity• Semaphores, locks, etc• Message passing• Case studies

Page 9: What I Teach (Do what I say, not what I do)

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}

Page 10: What I Teach (Do what I say, not what I do)

Critical Section Problemsem mutex = 1;

process CS[i = 1 to n] { while (true) { P(mutex); critical section; V(mutex); noncritical section; }}

Page 11: What I Teach (Do what I say, not what I do)

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)?

Page 12: What I Teach (Do what I say, not what I do)

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)}

Page 13: What I Teach (Do what I say, not what I do)

Correctness

{V = ( : in(CS j )j∑ ∨after(CS j ) :1)}

entry i

{V +1= ( : in(CS j )j∑ ∨after(CS j ) :1)}

Page 14: What I Teach (Do what I say, not what I do)

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)}

Page 15: What I Teach (Do what I say, not what I do)

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)

Page 16: What I Teach (Do what I say, not what I do)

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)

Page 17: What I Teach (Do what I say, not what I do)