Presentation is loading. Please wait.

Presentation is loading. Please wait.

非同期マルチキャスト通 信を行う言語 Scope の操 作的意味 増山隆

Similar presentations


Presentation on theme: "非同期マルチキャスト通 信を行う言語 Scope の操 作的意味 増山隆"— Presentation transcript:

1 非同期マルチキャスト通 信を行う言語 Scope の操 作的意味 増山隆 tak@yl.is.s.u-tokyo.ac.jp

2 Outline Introduction  Scope Language Operational semantics  Translation to Abstract syntax  Reduction rules Future work Related work

3 Outline Introduction - Scope Language Operational Semantics  Translation to Abstract syntax  Reduction rules Future work Related work

4 What is Scope? Language to write distributed application based on  Typed communication  decoupled communication  Asynchronous by nature of distributed system Consequence: Implicit type-based multicast language

5 Component definition (when) component Echo { when(T x) { send(x); } activate() { send(new T());}} Wait for arrival of a event typed T and for activation Execute clause corresponding with a type of received event

6 Component definition (send) component Echo { when(T x) { send(x); } activate() { send(new T());}} send event asynchronously

7 Script (instantiate) p=instantiate(Echo); q=instantiate(Echo); connect(p, q, T); connect(q, p, T); activate(p); Instantiate components They run concurrently

8 Script (connect) p=instantiate(Echo); q=instantiate(Echo); connect(p, q, T); connect(q, p, T); activate(p); Enable p to send events typed T to q

9 Component definition (activate) p=instantiate(Echo); q=instantiate(Echo); connect(p, q, T); connect(q, p, T); activate(p); Activate p to start program

10 Type based multicast p=instantiate(Echo); q=instantiate(Echo); r=instantiate(Echo); connect(p, q, T); connect(p, r, T); activate(p); p sends event typed T to q and r

11 Ordered communication component Echo2 { when(T x) { send(T(1)); send(T(2)); } } T(1) and T(2) are received in this order, because they have same Event type T

12 Component definition (activate) p=instantiate(Echo); q=instantiate(Echo); connect(p, q, T); connect(q, p, T); activate(p); Activate p to start program

13 Outline Introduction  Scope Language Operational Semantics  Translation to Abstract syntax  Reduction rules Future work Related work

14 Translation to abstract syntax Scope component Echo { when (T x) {... } } Abstract Syntax i(x:T).o.Echo(i,o) introduce channel names

15 Concrete syntax (Scope Language) Component definition  when  send Script  instantiate  connect

16 Abstract syntax P ::= (νx : chan T ) P (* introduce channel *) | Par Par ::= x ~ C | Par (* parallel *) | ε P W ::= i(x : T). S + W (* input guarded sums (when) *) | ε w S ::= o. S (* computations (in when clauses) *) | X(i 1,...,i n, o 1,...,o m )

17 Translation (when clause) component Echo { when(T x) { send(x); } activate() { send(new T());}} i T (x:T). when clause is translated into input prefix

18 Translation (send) component Echo { when(T x) { send(x); } activate() { send(new T());}} i T (x:T).o T. send is translated into output prefix

19 Translation (multiple when clauses) component Echo { when(T x) { send(x); } activate() { send(new T());}} i T (x:T).o T.Echo(i T,o T ) +i A (x:A).o T.Echo(i T,o T ) multiple when clauses are translated into sum

20 Translation (component definition) component Echo { when(T x) { send(x); } when(A x) { send(new T());}} Echo(i T,o T ) = i T (x:T).o T.Echo(i T,o T ) +i A (x:T).o T.Echo(i T,o T )

21 Translation (instantiation) p1 = instantiate(p1); p2 = instantiate(p2); connect(p1, p2, T); connect(p2, p1, T); activate(p1) p1 ~ Echo(i T, o T ) | p2 ~ Echo(i' T,o' T ) instantiate is translated into parallel

22 Translation (connect) p1 = instantiate(p1); p2 = instantiate(p2); connect(p1, p2, T); connect(p2, p1, T); activate(p1) (νc:chan T ) p1 ~ Echo(i T,c) | p2 ~ Echo(c,o' T ) connect introduces new channel name and unify names of end points

23 Translation (connect) p1 = instantiate(p1); p2 = instantiate(p2); connect(p1, p2, T); connect(p2, p1, T); activate(p1) (νd:chan T ) (νc:chan T ) p1 ~ Echo(d, c) | p2 ~ Echo(c, d) connect introduces new channel name and unify names of end points

24 Outline Introduction  Scope Language Operational semantics  Translation to abstract syntax  Reduction rules Future work Related work

25 Operational semantics Asynchronous ordered communication  Use buffer with respect to each pair of sender and type e.g.) An Echo instance needs one buffer for events with type T Type based multicast  Give unique name to each instance to specify receivers of event

26 Meaning of transitional rule C |- P → C' |- P' C represents states of channels P represents component processes

27 Example of reduction E(i T,o T ) = i T (x:T).o T.E(i T,o T ) + i A (x:T).o T.E(i T,o T ) P = (νd:chan T ) (νc:chan T ) p1 ~ E(c, d) | p2 ~ E(d, c) Initially, channel i A has one event which will be received by p1 (corresponding to activate)

28 introduce new channel (NEW) (νd:chan T ) (νc:chan T ) p1 ~ E(d, c) | p2 ~ E(c, d) i A :chan A = [a {p1} ] |- → (νc:chan T ) p1 = E(d', c) | p2 = E(c, d') i A :chan A = [a {p1} ] d':chanT = ε |-

29 introduce new channel (NEW) → p1 = E(d', c') | p2 = E(c', d') i A :chan A = [a {p1} ] d':chanT = ε |- c':chanT = ε → (νc:chan T ) p1 = E(d', c) | p2 = E(c, d') i A : chan A = [a {p1} ] d':chanT = ε |-

30 Receive an event (IN) → p1 ~..+i A (x:T).c' T.E(d' T,c' T ) | p2 ~ E(c' T,d' T ) i A :chan A =[a {p1} ] d':chanT = ε |- c':chanT = ε → i A :chan A = ε d':chanT = ε |- c':chanT = ε p1 ~ (c' T.E(d' T,c' T ))[a/x] | p2 ~ E(c' T,d' T )

31 Send an event (MULTI-OUT) → i A :chan A = ε d':chanT = ε |- c':chanT = ε p1 ~..+c' T.E(d' T,c' T ) | p2 ~ E(c' T,d' T ) → i A :chan A = ε d':chanT = ε |- c':chanT = [T() {p2} ] p1 ~ E(d' T,c' T ) | p2 ~ E(c' T,d' T ) ∵ sink of channel c' is p2

32 Send an event (MULTI-OUT) if there is one more receiver p3 → i A :chan A = ε d':chanT = ε |- c':chanT = ε p1 ~..+c' T.E(d' T,c' T ) | p2 ~ E(c' T,d' T ) | p3 ~ E(c' T,d' T ) → i A :chan A = ε d':chanT = ε |- c':chanT = [T() {p2,p3} ] p1 ~ E(d' T,c' T ) | p2 ~ E(c' T,d' T ) | p3 ~ E(c' T,d' T ) ∵ sink of channel c' are p2 and p3

33 Example of multicast and ordered communication On the blackbord R(i T ) = i T (x:T). R(i T ) S(i A, o T ) = o T. o T. R(i T ) (νc:chan T ) r1 ~ R(c) | r2 ~ R(c) | s = S(i A, c)

34 Multiple sender vs. one receiver P = (νd:chan T ) (νc:chan T ) s1 ~ E(*, d) | s2 ~ E(*, c) | r ~ E(c,*) + E(d, *) A receiver r becomes sum.

35 Future work Finalize the operational semantics (in modular way)  Embedded λ-calculus  Sub-typing of event  Unicast communication Add mobility to semantics and implementation  Component migration  Channel passing

36 Related work B.C.Pierce, Programming in the Pi- Calculus (Pict)  Programming language based on pi-calculus  Communications are asynchronous http://www.cis.upenn.edu/~bcpierce/papers/pict/Html/Pict.html Distributed pi-calculus


Download ppt "非同期マルチキャスト通 信を行う言語 Scope の操 作的意味 増山隆"

Similar presentations


Ads by Google