An Observational Theory of Imperative Concurrent Data Structures in - - PowerPoint PPT Presentation

an observational theory of imperative concurrent data
SMART_READER_LITE
LIVE PREVIEW

An Observational Theory of Imperative Concurrent Data Structures in - - PowerPoint PPT Presentation

An Observational Theory of Imperative Concurrent Data Structures in the -Calculus Luca Fossati Kohei Honda Electronics, Engineering and Computer Science Queen Mary University of London Lisboa, 19/04/2011 An Observational Theory of Imperative


slide-1
SLIDE 1

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus

Luca Fossati Kohei Honda Electronics, Engineering and Computer Science Queen Mary University of London Lisboa, 19/04/2011

slide-2
SLIDE 2

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 1/40

Intro

Traditional global progress properties of concurrent programs :

  • Deadlock-Freedom
  • Starvation-Freedom

Fossati, Honda - 2011

slide-3
SLIDE 3

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 2/40

Intro

Traditional global progress properties of concurrent programs :

  • Deadlock-Freedom
  • Starvation-Freedom

⇓ Critical section → Lock-based only

Fossati, Honda - 2011

slide-4
SLIDE 4

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 3/40

Intro

A more general approach :

  • Non-Blockingness
  • Wait-Freedom

Fossati, Honda - 2011

slide-5
SLIDE 5

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 4/40

Intro

A more general approach :

  • Non-Blockingness
  • Wait-Freedom

⇑ Abstraction ⇑ Extensionality

Fossati, Honda - 2011

slide-6
SLIDE 6

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 5/40

Intro

A more general approach :

  • Non-Blockingness
  • Wait-Freedom

⇑ Abstraction ⇑ Extensionality ⇓ Lack of rigorous semantic basis

Fossati, Honda - 2011

slide-7
SLIDE 7

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 6/40

Intro

Non-Blockingness “A data structure is non-blocking if it guarantees that some process will always be able to complete its pending

  • peration in a finite number of its own steps, regardless of

the execution speed of other processes.” [Taubenfeld, ’06]

Fossati, Honda - 2011

slide-8
SLIDE 8

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 7/40

Intro

How to formalise:

  • “a finite number of its own steps”
  • “regardless of the execution speed of other processes”

?

Fossati, Honda - 2011

slide-9
SLIDE 9

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 8/40

Intro

How to formalise:

  • “a finite number of its own steps”
  • “regardless of the execution speed of other processes”

⇒ Fairness ⇒ Partial Failures

Fossati, Honda - 2011

slide-10
SLIDE 10

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 9/40

Intro

How to formalise:

  • “a finite number of its own steps”
  • “regardless of the execution speed of other processes”

⇒ Fairness ⇒ Partial Failures ⇒ π-calculus

Fossati, Honda - 2011

slide-11
SLIDE 11

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 10/40

Intro

AIM : To provide an extensional theory which is general enough to cover all the concurrent data structures whose behaviours are representable in the π-calculus.

Fossati, Honda - 2011

slide-12
SLIDE 12

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 11/40

Index

  • π-calculus
  • Linear/Affine Types
  • Asynchronous fair LTS + partial failures
  • Global Progress :

– Non-blockingness – Wait-Freedom

  • Case study : Queues

– Correctness (state space) – Behavioural Classification

Fossati, Honda - 2011

slide-13
SLIDE 13

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 12/40

The Calculus

P ::= u&i∈I{li( xi).Pi} | u ⊕ l e | if e then P else Q | P|Q | (νu)P | (µX( x).P) e | X x |

Fossati, Honda - 2011

slide-14
SLIDE 14

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 13/40

Reductions

One rule: u&i∈I{li( xi).Pi} | u ⊕ lj e − → Pj{ e/ xj} (j ∈ I) Closed under the standard structural congruence, ≡. Note in particular: (µX( x).P) e ≡ P{(µX( x).P)/X}{ e/ x}

Fossati, Honda - 2011

slide-15
SLIDE 15

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 14/40

Example

Some simple concurrent data structures : Refu, v

def

= u&    read(z) : zv | Refu, v, write(y, z) : z | Refu, y    Refcasu, v

def

= u&              read(z) : zv | Refcasu, v, write(y, z) : z | Refcasu, y, cas(x, y, z) : if x=v then ztt | Refcasu, y else zff | Refcasu, v             

Fossati, Honda - 2011

slide-16
SLIDE 16

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 15/40

Example

Reduction : Refcasa, 0|(νc)(a⊕cas0, 1, c|c(x).P) − → (νc)((if 0 = 0 then ctt | Refcasa, 1 else cff | Refcasa, 0) | c(x).P) − → (νc)((if tt then ctt | Refcasa, 1 else cff | Refcasa, 0) | c(x).P) − →∗ Refcasa, 1 | P{tt/x}

Fossati, Honda - 2011

slide-17
SLIDE 17

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 16/40

Example

Two different mutex agents: Mtxu

def

= u(x).x(h)h.Mtxu Mtxspinu

def

= (νc)(!u(x).µX. (if cas(c, 0, 1) then x(h)h.CAS(c, 1, 0) else ) | Refcasc, 0) where if cas(u, v, w) then P else Q

def

= (νc)(u⊕casv, w, c|c(x).if x then P else Q) and CAS(u, v, w)

def

= if cas(u, v, w) then 0 else 0

Fossati, Honda - 2011

slide-18
SLIDE 18

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 17/40

Types

τ ::= &M

i∈Ili(

τi) | ⊕M

i∈Ili(

τi) | int | bool | ⊥ Modalities (as in Linear Logic, Games, . . . ): L channel can be used “exactly once” (linear) A channel can be used “at most once” (affine) L* input end always available and shared by unboundedly many

  • utputs (unbounded l.)

A* input end as above but may be unavailable (unbounded a.)

Fossati, Honda - 2011

slide-19
SLIDE 19

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 18/40

Example

Typings for the previously introduced examples : 1. u : &L∗{read(↑L(nat)), write(nat ↑L())} ⊢ Refu, 3 2. u : &L∗{read(↑L(nat)), write(nat ↑L()), cas(natnat ↑L(bool)), } ⊢ Refcasu, 0 3. u :↓A∗(↑A(↓A())) ⊢ P ( P ∈ {Mtxu, Mtxspinu} )

Fossati, Honda - 2011

slide-20
SLIDE 20

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 19/40

Labelled Transition System

Labels : ℓ ::= τ | (ν c)a&l( v) | (ν c)a ⊕ l v Untyped transitions : (Bra) P

(ν c)a&l v

− → P|a ⊕ l v (Sel) (ν c)(P|a ⊕ l v)

(ν c)a⊕l v

− → P

Fossati, Honda - 2011

slide-21
SLIDE 21

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 20/40

Labelled Transition System

Environment transitions : Γ, a : &L∗,A∗{li( τi)}i∈I

(ν c)a&lj vj

− → Γ ⊙ v : τj, a : &L∗,A∗{li( τi)}i∈I (Γ ⊙ v : τj)/ c, a : ⊕L∗,A∗{li( τi)}i∈I

(ν c)a⊕lj vj

− → Γ, a : ⊕L∗,A∗{li( τi)}i∈I Γ, a : &L,A{li( τi)}i∈I

(ν c)a&lj vj

− → Γ ⊙ v : τj, a : ⊥ (Γ ⊙ v : τj)/ c, a : ⊕L,A{li( τi)}i∈I

(ν c)a⊕lj vj

− → Γ Typed transitions : Γ ⊢ P

− → Γ′ ⊢ P ′

def

⇔ P

− → P ′ ∧ Γ

− → Γ′

Fossati, Honda - 2011

slide-22
SLIDE 22

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 21/40

Bisimilarity

Definition 3.3 (bisimilarity) A typed relation R is a weak bisimulation or often bisimulation when, for each Γ ⊢ PRQ, we have: P

− → P ′ implies Q

ˆ ℓ

= ⇒ Q′ s.t. P ′RQ′, and the symmetric

  • case. The maximum bisimulation is written ≈.

Proposition 3.4 ≈ is a typed congruence.

Fossati, Honda - 2011

slide-23
SLIDE 23

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 22/40

Fairness

Definition 3.5 (Fairness) A maximal transition sequence Φ from closed Γ ⊢ P is fair if no subject is infinitely often enabled in Φ.

Fossati, Honda - 2011

slide-24
SLIDE 24

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 23/40

Fairness

Definition 3.5 (Fairness) A maximal transition sequence Φ from closed Γ ⊢ P is fair if no subject is infinitely often enabled in Φ. Let P =!a.(b|a)|a and Q = Refr, 3|r ⊕ readc. Then P|Q admits an infinite unfair transition sequence.

Fossati, Honda - 2011

slide-25
SLIDE 25

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 24/40

Fairness

Definition 3.5 (Fairness) A maximal transition sequence Φ from closed Γ ⊢ P is fair if no subject is infinitely often enabled in Φ. Let P =!a.(b|a)|a and Q = Refr, 3|r ⊕ readc. Then P|Q admits an infinite unfair transition sequence. Fairness induces a fair pre-order fair, where: P fair Q ⇐ ⇒ P ≈ Q ∧ WFT(P) ⊇ WFT(Q)

Fossati, Honda - 2011

slide-26
SLIDE 26

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 25/40

Partial Failure

We first augment the dynamics with failing reductions: u ⊕Mlj e − → 0 (M = L) if v then P else Q − → 0 Then we augment the τ-transition accordingly. NOTE : Only affine outputs may fail! ⇓ Linearity ⇒ Atomicity

Fossati, Honda - 2011

slide-27
SLIDE 27

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 26/40

Global Progress

Definition 3.11 (Resilience) Let Γ ⊢ P such that for all wft(Φ) ∈ WFT(P), the set blocked(Φ) is finite. Then we say that Γ ⊢ P is resilient. Definition 3.12 (NB/WF) A closed process Γ ⊢ P is:

  • 1. non-blocking (NB) when it is resilient and, for any Φ∈FT(P)

s.t. ∆⊢Q is in Φ and allowed(∆) \ blocked(Φ)=∅, some affine output occurs in Φ.

  • 2. wait-free (WF) when it is resilient and, for any Φ ∈ FT(P) s.t.

∆ ⊢ Q is in Φ and c ∈ allowed(∆) \ blocked(Φ), an output at c occurs in Φ.

Fossati, Honda - 2011

slide-28
SLIDE 28

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 27/40

Weak Global Progress

Let WNB be as NB but without failures. Let WWF be as WF but without failures. Then WF NB ∩ WWF and NB ∪ WWF WNB.

Fossati, Honda - 2011

slide-29
SLIDE 29

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 28/40

Abstract Queue Specification

Abstract Queue: AQ(r, Rs; Vs; As)

Fossati, Honda - 2011

slide-30
SLIDE 30

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 29/40

Abstract Queue Specification

Abstract Queue: AQ(r, Rs; Vs; As) Example: AQ(r, {enq(6, g1), deq(g2)}, 2·3·1, {g35})

Fossati, Honda - 2011

slide-31
SLIDE 31

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 30/40

State Space Abstraction

Abstract Queue: AQ(r, Rs; Vs; As) State Transitions

AQ(r, Rs, Vs, As)

r&enq(v,g)

− → AQ(r, Rs ⊎ enq(v, g), Vs, As) AQ(r, Rs, Vs, As)

r&deq(g)

− → AQ(r, Rs ⊎ deq(g), Vs, As) AQ(r, Rs ⊎ enq(v, g), Vs, As)

τ

− → AQ(r, Rs, Vs·v, As ⊎ g) AQ(r, Rs ⊎ deq(g), v·Vs, As)

τ

− → AQ(r, Rs, Vs, As ⊎ {gv}) AQ(r, Rs ⊎ deq(g), , As)

τ

− → AQ(r, Rs, , As ⊎ {gKO}) AQ(r, Rs, Vs, As ⊎ {gv})

gv

− → AQ(r, Rs, Vs, As)

Fossati, Honda - 2011

slide-32
SLIDE 32

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 31/40

cas-based Queue in π

Auxiliary data structures : Node(r, v, ptr)

def

= Refr, v, ptr Ptr(r, nd, ctr)

def

= Refcasr, nd, ctr Shortened forms : x ⊳ read( y).P

def

= (νc)(x ⊕ readc|c( y).P) We use ad-hoc names when we only want to keep a projection of the contents (getPtr, getV al, . . . ).

Fossati, Honda - 2011

slide-33
SLIDE 33

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 32/40

cas-based Queue in π

CQemp(r)

def

= (νh)(νt)(νs)(CQ(r, h, t) | Ptr(h, s, 0) | Ptr(t, s, 0) | Node(s, 0, null)) CQ(r, h, t)

def

= r&                enqueue(x, u) : (CQ(r, h, t) | Penq(x, t)) dequeue(u) : (CQ(r, h, t) | Pdeq(h, t))               

Fossati, Honda - 2011

slide-34
SLIDE 34

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 33/40

cas-based Queue in π

Penq(x, tail) = NullPtr(nlPtr) | Node(node, v, nlPtr) | (µXtag(u′). tail ⊳ read(last, ctrT). last ⊳ getPtr(tPtr). tPtr ⊳ read(next, ctr). if (next = null) then if cas(tPtr, next, ctr, node, ctr + 1) then if cas(tail, last, ctrT, node, ctrT + 1) then u′ else u′ else Xtagu′) else if cas(tail, last, ctrT, next, ctrT + 1) then Xtagu′ else Xtagu′) endif)u

Fossati, Honda - 2011

slide-35
SLIDE 35

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 34/40

cas-based Queue in π

Pdeq(head, tail) = (µXtag(u′). head ⊳ read(hNdRef, ctrH). tail ⊳ read(tNdRef, ctrT). hNdRef ⊳ getPtr(hNdPtr). hNdPtr ⊳ getNxt(next). if (hNdRef = tNdRef) then if (next = null) then u′null else if (cas(tail, tNdRef, ctrT, next, ctrT + 1)) then Xtagu′ else Xtagu′) else next ⊳ getV al(x). if (cas(head, hNdRef, ctrH, next, ctr + 1)) then u′x else Xtagu′)u

Fossati, Honda - 2011

slide-36
SLIDE 36

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 35/40

Lock-Based Queue in π

LQemp(r)

def

= (νu)(νh)(νt)(νs)(LQ(r, h, t)|Mtxu| LPtr(h, s)|LPtr(t, s)|LENode(s, 0)) LQ(r, h, t, l)

def

= r&              enqueue(v, u) : LQ(r, h, t, l)| (l(g)g(y).P lck

enq(v, t, c′)|c′.(¯

y|¯ u)), dequeue(u) : LQ(r, h, t, l)| (l(g)g(y).P lck

deq(h, t, c′)|c′.(¯

y|¯ u))             

Fossati, Honda - 2011

slide-37
SLIDE 37

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 36/40

Correctness

  • state space abstraction (correctness by bisimilarity)
  • molecular transitions (atomic operation)
  • commit event (i.e. cas on successor pointer)
  • normal form (each thread is either:
  • 1. ready to commit,
  • 2. or ready to output)
  • normalisation through linearisation (local permutations)

Fossati, Honda - 2011

slide-38
SLIDE 38

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 37/40

Global Progress

Proposition 4.6 Let Φ : CQemp(r) − →∗ P be a queue process. Then an output is blocked in Φ iff its thread fails in Φ. Proposition 4.8 ΓQ ⊢ CQemp(r) is non-blocking.

Fossati, Honda - 2011

slide-39
SLIDE 39

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 38/40

Behavioural Classification

ΓQ ⊢ LQemp(r) is blocking (it is weakly wait-free). ΓQ ⊢ LQemp(r) has more fair sequences Theorem 4.11 AQ(r, ε) ≈ LQemp(r) fair CQemp(r)

Fossati, Honda - 2011

slide-40
SLIDE 40

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 39/40

Results and Future Works

  • Fairness
  • Fine-grained analysis
  • Generality
  • Extensionality
  • State space abstraction

⇒ Automated verification tools ⇒ Encoding from imperative languages

Fossati, Honda - 2011

slide-41
SLIDE 41

An Observational Theory of Imperative Concurrent Data Structures in the π-Calculus 40/40

References

[1] D. Cacciagrano, F. Corradini and C. Palamidessi. Fair π.

  • Proc. EXPRESS’06. ENTCS, 175:3–26. Elsevier Science, 2007.

[2] M. M. Michael and M. L. Scott. Simple, fast, and practical non-blocking and blocking concurrent queue algorithms. PODC-15. 267–275. ACM, 1996. [3] R. Milner and J. G. Parrow and D. J. Walker, A calculus of Mobile Processes, Information and Computation 100(1), 1–77, 1992. [4] G. Taubenfeld. Synchronization Algorithms and Concurrent

  • Programming. Pearson–Prentice Hall, 2006.

Thank you for your attention!

Fossati, Honda - 2011