Eventful Sessions: Eventful Sessions: Types, Programming and - - PowerPoint PPT Presentation

eventful sessions eventful sessions types programming and
SMART_READER_LITE
LIVE PREVIEW

Eventful Sessions: Eventful Sessions: Types, Programming and - - PowerPoint PPT Presentation

Eventful Sessions: Eventful Sessions: Types, Programming and Bisimilarity Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida Kohei Honda Type safe Eventful Sessions in Java Type safe Eventful Sessions in Java Combine session


slide-1
SLIDE 1

Eventful Sessions: Eventful Sessions: Types, Programming and Bisimilarity

Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida Kohei Honda

slide-2
SLIDE 2

Type safe Eventful Sessions in Java Type‐safe Eventful Sessions in Java

  • Combine session types and event driven programming
  • Combine session types and event‐driven programming

– Extend session types to support event‐driven programming yp pp p g g – Facilitate event‐driven programming using the benefits of session types

2 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-3
SLIDE 3

Outline Outline

  • Extend SJ (Session Java) for session‐typed event programming

Extend SJ (Session Java) for session typed event programming. (ECOOP ‘10)

  • Supporting formalisation of the key mechanisms in a minimal process

model; communication safety for eventful session processes.

  • Behavioural theory for asynchronous, eventful processes.

(FMOODS ‘11) ( )

3 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-4
SLIDE 4

Event driven Concurrency Event‐driven Concurrency

  • … vs. multithreaded concurrency

Multithreaded Server www.server.co.uk:8888

4 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-5
SLIDE 5

Event driven Concurrency Event‐driven Concurrency

  • … vs. multithreaded concurrency

Multithreaded Server

5 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-6
SLIDE 6

Event driven Concurrency Event‐driven Concurrency

  • … vs. multithreaded concurrency

Multithreaded Server

6 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-7
SLIDE 7

Event driven Concurrency Event‐driven Concurrency

  • … vs. multithreaded concurrency

Multithreaded Server

8 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-8
SLIDE 8

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

9 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-9
SLIDE 9

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

10 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-10
SLIDE 10

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

11 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-11
SLIDE 11

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

12 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-12
SLIDE 12

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

13 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-13
SLIDE 13

Event driven Concurrency Event‐driven Concurrency

+ scalability

Selector E t L Event‐driven Server Event Loop

14 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-14
SLIDE 14

Event driven Concurrency Event‐driven Concurrency

+ scalability – difficult (read/write/verify)

– Fragmented control flow – Low level

Selector E t L Event‐driven Server Event Loop

15 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-15
SLIDE 15

Event driven Concurrency Event‐driven Concurrency

+ scalability – difficult (read/write/verify)

– Fragmented control flow – Low level

Selector E t L Event‐driven Server Event Loop Thread

16 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-16
SLIDE 16

Event driven Concurrency Event‐driven Concurrency

+ scalability – difficult (read/write/verify)

– Fragmented control flow – Low level

Selector E t L Event‐driven Server Event Loop Event Loop

17 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-17
SLIDE 17

Language and Runtime for Events Language and Runtime for Events

Language features for event‐driven programming…

  • Events can make Sense. M. Krohn, E. Kohler, and M. F. Kaashoek. (USENIX ATC

2007.)

  • EventJava: An Extension of Java for Event Correlation. P. Eugster and K. R.
  • Jayaram. (ECOOP 2009.)

Alternative programming interfaces over event‐driven runtimes…

  • Combining Events and Threads for Scalable Network Services. P. Li and S.
  • Zdancewic. (PLDI 2007.)
  • Scala Actors: Unifying Thread‐based and Event‐based Programming. P. Haller

d M Od k (TCS 2009 ) and M. Odersky. (TCS 2009.)

  • Capriccio: Scalable Threads for Internet Services. Capriccio R. von Behren, J.

Condit, F. Zhou, G. C. Necula, and E. Brewer. (SOSP 2003.)

18 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

Condit, F. Zhou, G. C. Necula, and E. Brewer. (SOSP 2003.)

slide-18
SLIDE 18

Session Types Session Types

Theory…

  • Language Primitives and Type Disciplines for Structured Communication‐based
  • Programming. K. Honda, V. T. Vasconcelos, and M. Kubo. (ESOP 1998.)

S i t f Obj t i t d L M D i Ci li i D M t

  • Session types for Object‐oriented Languages. M. Dezani‐Ciancaglini, D. Mostrous,
  • N. Yoshida, and S. Drossopoulou. (ECOOP 2006.)

l l d d l Practical language design and implementations…

  • Session‐based Distributed Programming in Java. R. Hu, N. Yoshida, and K. Honda.

(ECOOP 2008 ) (ECOOP 2008.)

  • Modular Session Types for Distributed Object‐oriented Programming. S. J. Gay, V.
  • T. Vasconcelos, A. Ravara, N. Gesbert, and A. Z. Caldeira. (POPL 2010.)
  • Language Support for Fast and Reliable Message‐based Communication in

Singularity OS. Fähndrich, M. Aiken, C. Hawblitzel, O. Hodson, G. Hunt, J. R. Larus, and S Levi (EuroSys 2006 )

19 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

and S. Levi. (EuroSys 2006.)

slide-19
SLIDE 19

Type safe Eventful Sessions in Java Type‐safe Eventful Sessions in Java

begin .!< Background, Contributions > .!< Basic Example > .!< Formalism and Properties > p .!< Implementation, Real‐world Example: SMTP > .!< Conclusion > .?[ ?( Question ) !< Answer > ?( Question ).!< Answer > ]* .end

20 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-20
SLIDE 20

Session typed Programming Session‐typed Programming

  • Handle concurrent sessions of type:

?( ) ?( ) ! l ?(Data).?(Data).!<Result>

Session‐based communications programming in SJ:

  • Declaration of communication protocols using session types
  • Declaration of communication protocols using session types
  • Implementation of protocols using statically type‐checked

i ti session operations

21 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-21
SLIDE 21

Session typed Programming Session‐typed Programming

  • Handle concurrent sessions of type:

?( ) ?( ) ! l ?(Data).?(Data).!<Result>

22 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-22
SLIDE 22

Session typed Programming Session‐typed Programming

  • Handle concurrent sessions of type:

l { ?( ) ?( ) ! l } protocol pServer { ?(Data).?(Data).!<Result> }

23 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-23
SLIDE 23

Session typed Programming Session‐typed Programming

  • Handle concurrent sessions of type:

l { ?( ) ?( ) ! l } protocol pServer { ?(Data).?(Data).!<Result> } ... SJSocket{pServer} s = ss.accept(); ... Data d1 = s receive(); // ?(Data) Data d1 = s.receive(); // ?(Data) Data d2 = s.receive(); // ?(Data) Result r = doSomeWork(d1, d2); s.send(r); // !<Result>

24 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-24
SLIDE 24

Session typed Event Programming Session‐typed Event Programming

  • Handle concurrent sessions of type:

l { ?( ) ?( ) ! l } protocol pServer { ?(Data).?(Data).!<Result> } E t 2 Event 1 Event 2

25 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-25
SLIDE 25

Session typed Event Programming Session‐typed Event Programming

  • Handle concurrent sessions of type:

l { ?( ) ?( ) ! l } protocol pServer { ?(Data).?(Data).!<Result> } E t 2 // Session set type Event 1 Event 2 // Session set type protocol pSelector { ?(Data).?(Data).!<Result>, // Event 1 ?(Data).!<Result> // Event 2 }

26 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-26
SLIDE 26

Event driven Concurrency Event‐driven Concurrency

Selector E t L Event‐driven Server Event Loop

27 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

slide-27
SLIDE 27

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } } }

28 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} }

slide-28
SLIDE 28

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); } }

29 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} }

slide-29
SLIDE 29

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... } }

30 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} }

slide-30
SLIDE 30

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ...

Session Socket endpoint: Session Socket endpoint:

SJSocket{?(Data).?(Data).!<Result>}

} }

31 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} }

slide-31
SLIDE 31

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) { using(SJSocket{pSelector} s = sel.select()) { } } } }

32 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } }

slide-32
SLIDE 32

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) { using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { // Event 1 Data d1 = s1.receive(); // ?(Data) (); // ( ) sel.register(s1); // ?(Data).!<Result> } } } } } }

33 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-33
SLIDE 33

Session typed Event Programming Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException { public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) { using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) { // Event 2 Data d2 = s2.receive(); // ?(Data) s2.send(new Result(...)); // !<Result> } } } } } }

34 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-34
SLIDE 34

Session typed Event Programming

Explicit specification of

Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException {

Explicit specification of system events

public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) { using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) { Data d2 = s2.receive(); s2.send(new Result(...)); } } } } } }

35 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-35
SLIDE 35

Session typed Event Programming

Explicit specification of

Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException {

Explicit specification of system events

public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) {

Precise specification of each event

using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) { Data d2 = s2.receive(); s2.send(new Result(...)); } } } } } }

36 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-36
SLIDE 36

Session typed Event Programming

Explicit specification of

Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException {

Explicit specification of system events

public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) {

Precise specification of each event

using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) { Data d2 = s2.receive(); s2.send(new Result(...)); } } } } } }

37 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-37
SLIDE 37

Session typed Event Programming

Explicit specification of

Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException {

Explicit specification of system events

public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) {

Precise specification of each event

using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) {

Correct matching of events to event handlers

Data d2 = s2.receive(); s2.send(new Result(...)); } } } } } }

38 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

slide-38
SLIDE 38

Session typed Event Programming

Explicit specification of

Session‐typed Event Programming

class Example { public static void main(String[] args) throws SJIOException {

Explicit specification of system events

public static void main(String[] args) throws SJIOException { protocol pSelector { ?(Data).?(Data).!<Result>, ?(Data).!<Result> } SJSelector{pSelector} sel = new SJSelector{pSelector}(); ... sel.register(client); ... while(run) { // Main event loop. sing(SJSocket{ S l t } l select()) {

Precise specification of each event

using(SJSocket{pSelector} s = sel.select()) { typecase(s) { when(SJSocket{?(Data).?(Data).!<Result>} s1) { Data d1 = s1.receive(); (); sel.register(s1); } when(SJSocket{?(Data).!<Result>} s2) {

Correct matching of events to event handlers

Data d2 = s2.receive(); s2.send(new Result(...)); } } } } } }

Correct handling of each event; preservation of session flow

39 Raymond Hu, Dimitrios Kouzapas, Olivier Pernet, Nobuko Yoshida, Kohei Honda

} } } } }

preservation of session flow across event boundaries

slide-39
SLIDE 39

A Typing System for the Eventful Session π-Calculus

Typing judgement for ESP Γ ⊢ P ⊲ ∆ where Γ ::= ∅ | Γ · v : S | Γ · X : ∆ ∆ ::= ∅ | ∆ · k : T | ∆ · a U ::= bool | iS | oS | X | µX.U T ::= U S ::= !T; S | ?(T); S | ⊕ {li : Si}i∈I | &{li : Si}i∈I | {Si}i∈I | µX.S | X | end Subject Reduction Theorem Let Γ ⊢ P ⊲ ∆ with wc(∆). Then if P → → Q then Γ ⊢ Q ⊲ ∆′ with ∆ → → ∆′ and wc(∆′).

slide-40
SLIDE 40

Labeled Transition System

Local (the dashed arrows) s!v; Q | s[o : h]

τ

− → Q | s[o : h · v] s?(x); P | s[i : w · h]

τ

− → P{w/x} | s[i : h] Remote (the solid arrows) s[i : h]

s?v

− → s[i : h · v] s[o : v · h]

s!v

− → s[o : h]

slide-41
SLIDE 41

Typed Transition/Reduction - Localisation

◮ Typed transition: Γ ⊢ P ⊲ ∆ ℓ

− → P′ ⊲ ∆′ if

  • 1. P

− → P′ (ensures asynchrony)

  • 2. (Γ, ∆)

− → (Γ′, ∆′) (ensures linearity)

◮ P is localised with respect to Γ, ∆ if

  • 1. For each s : S ∈ dom(∆), s ∈ ∆
  • 2. if Γ(a) = iS, then a ∈ ∆.

◮ A relation Γ ⊢ P ⊲ ∆1 R Γ ⊢ Q ⊲ ∆2 is called typed relation

if

  • 1. P, Q localised
  • 2. ∆1 −

→∗ ∆2 or ∆2 − →∗ ∆1.

slide-42
SLIDE 42

Typed Relations

◮ A typed relation R is called typed reduction congruence if

whenever PRQ then:

  • 1. If P ↓ a then Q ⇓ a
  • 2. If Γ ⊢ P ⊲ ∆1 −

→ P ⊲ ∆′

1 then Γ ⊢ Q ⊲ ∆2 →

→ Q ⊲ ∆′

2 and

PRQ.

  • 3. C[P]RC[Q]

Reduction congruency (∼ =) is the maximum (non-universal) reduction congruence.

◮ A typed relation R is a weak asynchronous session

bisimulation if, whenever Γ ⊢ P1 ⊲ ∆1RΓ ⊢ P2 ⊲ ∆2, then

  • 1. Γ ⊢ P1 ⊲ ∆1

− → P′

1 ⊲ ∆′ 1 implies Γ ⊢ P2 ⊲ ∆2 ˆ ℓ

= ⇒ P′

2 ⊲ ∆′ 2 such

that P′

1RP′ 2.

  • 2. the symmetric case.

Bisimilarity (≈) is the maximum bisimulation.

slide-43
SLIDE 43

Theorems

◮ Theorem (Soundness and Completeness) ≈ = ∼

=

◮ Asynchrony

s1!v1; s2!v2; 0 | s1[i : ǫ, o : ǫ] | s2[i : ǫ, o : ǫ] ≈ s2!v2; s1!v1; 0 | s1[i : ǫ, o : ǫ] | s2[i : ǫ, o : ǫ].

◮ Linearity

s!v1; s!v2; 0 | s1[i : ǫ, o : ǫ] | s2[i : ǫ, o : ǫ] ≈ s!v2; s!v1; 0 | s1[i : ǫ, o : ǫ] | s2[i : ǫ, o : ǫ].

◮ Arrive Semantics

Assume that P ≈ Q, then if arrive s then P else Q | s[i : ǫ] | s[o : v] ≈ if arrive s then P else Q | s[i : v] | s[o : ǫ].

◮ Clear distinctions between behavioural semantics for the

synchronous and the asynchronous π-calculi.

slide-44
SLIDE 44

Thread Elimination

◮ Lauer and Needham in 1979 observed that there is a duality

between threaded shared memory systems and event based message passing systems.

◮ A simple server has the form ∗ a(x).P | a[ǫ] where P is

confluent and handles each client in a sequential way.

◮ Define a transformation LN[

[∗ a(x).P | a[ǫ]] ] that handles clients on message reception events.

◮ Events are identified as the blocking session actions. ◮ Use a selector construct to select next client/session to handle.

slide-45
SLIDE 45

Thread Elimination: Mapping

LN[ [∗ a(x).P] ]

def

= (ν o, q, c)(Loopo, q | o | qa, c0 | CodeBlocksa, o, q, c) Loopo, q

def

= ∗ o.select x from q in typecase x of { (x : S, z : env) : new env yin zy, (x : S1, y : env, z : S1, env) : zx, y, . . . (x : Sn−m, y : env, z : Sn−m, env) : zx, y} CodeBlocksa, o, q, c

def

= B[ [a(x).P] ] |

  • 1≤i≤nB[

[Pi] ]

B[ [∗ a(x).P] ]

def

= ∗ c0.ya(w).update (y, w, w′) in register a, c0 to q in [ [P, y] ] B[ [x(i)?(z : T); Q] ]

def

= ∗ ci (x′, y).x′?(z′); update (y, z, z′) in update (y, x, x′) in [ [Q, y] ] B[ [x(i)&{lj : Qj }j ] ]

def

= ∗ ci (x′, y).x′&{lj : update (y, x, x′) in [ [Qj , y] ]}j [ [x!e; Q, y] ]

def

= let x′ = [ [x] ]y in x′![ [e] ]y ; update (y, x, x′) in [ [Q, y] ] [ [x!k; Q, y] ]

def

= let x′ = [ [x] ]y in let k′ = [ [k] ]y in x′!k′; update (y, xk, x′k′) in [ [Q, y] ] [ [x ⊕ lj ; Q, y] ]

def

= let z = [ [x] ]y in z ⊕ lj ; [ [Q, y] ] [ [b(z : S); Q, y] ]

def

= b(z′ : S); update (y, z, z′) in [ [Q, y] ] [ [Q, y] ]

def

= let x′ = [ [x] ]y in register x′, ci , yqo (Q is blocking at x(i)) [ [0, y] ]

def

=

slide-46
SLIDE 46

Thread Elimination

Theorem: ∗ a(x).P | a[ǫ] ≈ LN[ [∗ a(x).P | a[ǫ]] ] For proofs, we use permutation, confluence and determinacy [Philippou and Walker’97] guaranteed by session types.

◮ ∗ a(x).P | a[ǫ] is confluent. ◮ LN[

[∗ a(x).P | a[ǫ]] ] processes events/clients in a sequential way.

slide-47
SLIDE 47

Conclusions

◮ Eventful Session Typed π-Calculus. ◮ Session typed behavioural semantics. ◮ Bisimulation is sound and complete with respect to

reduction-closed congruency.

◮ Permutations/confluence/determinacy properties enforced by

session types.

◮ Use the properties of bisimulations to prove a semantic

equivalence for a thread elimination transform [Lauer and Needham’79].

◮ D. Kouzapas, N. Yoshida and K. Honda. On Asynchronous

Session Semantics. To appear in FMOODS ’11. Full version with benchmarks in Eventful SJ: www.doc.ic.ac.uk/˜dk208/semantics.html