C. Varela1 Chapter 4: Actors Programming Distributed Computing Systems: A Foundational Approach Carlos Varela Rensselaer Polytechnic Institute.

Slides:



Advertisements
Similar presentations
Language and Automata Theory
Advertisements

Vered Gafni – Formal Development of Real Time Systems 1 Statecharts Semantics.
Formal Semantics of Programming Languages 虞慧群 Topic 6: Advanced Issues.
D u k e S y s t e m s Time, clocks, and consistency and the JMM Jeff Chase Duke University.
Event structures Mauro Piccolo. Interleaving Models Trace Languages:  computation described through a non-deterministic choice between all sequential.
Snap-stabilizing Committee Coordination Borzoo Bonakdarpour Stephane Devismes Franck Petit IEEE International Parallel and Distributed Processing Symposium.
Programming Paradigms for Concurrency Lecture 11 Part III – Message Passing Concurrency TexPoint fonts used in EMF. Read the TexPoint manual before you.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model From kernel to practical language (CTM 2.6) Exceptions (CTM.
Synchronization of Distributed Objects ICS280: Distributed System Middleware Xia Zhao
An Associative Broadcast Based Coordination Model for Distributed Processes James C. Browne Kevin Kane Hongxia Tian Department of Computer Sciences The.
CPSC 668Set 14: Simulations1 CPSC 668 Distributed Algorithms and Systems Spring 2008 Prof. Jennifer Welch.
Interface Automata 29-September Modeling Temporal Behavior of Component Component behaves with Environment Traditional (pessimistic) approach –
C. Varela1 Actors (PDCS 4) AMST actor language syntax, semantics, join continuations Carlos Varela Rennselaer Polytechnic Institute April 16, 2015.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
Ordering and Consistent Cuts Presented By Biswanath Panda.
An Introduction to Input/Output Automata Qihua Wang.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Single assignment store Kernel language syntax Carlos Varela.
1 Synchronization strategies for global computing models Ivan Lanese Computer Science Department University of Bologna.
Semantics of LOTOS Answering the question: Which processes are equivalent? Basic LOTOS: ignore ! and ?...pure synchronization Dining philosophers example:
FSM Decomposition using Partitions on States 290N: The Unknown Component Problem Lecture 24.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Kernel language semantics Carlos Varela RPI Adapted with permission.
 Idit Keidar, Principles of Reliable Distributed Systems, Technion EE, Spring Principles of Reliable Distributed Systems Lecture 6: Impossibility.
1 Ivan Lanese Computer Science Department University of Bologna Italy Concurrent and located synchronizations in π-calculus.
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
An algebra of Connectors for modeling CommUnity with Tiles joint work with Roberto Bruni Ugo Montanari Dipartimento di Informatica Università di Pisa Ivan.
Message Passing Systems A Formal Model. The System Topology – network (connected undirected graph) Processors (nodes) Communication channels (edges) Algorithm.
Message Passing Systems A Formal Model. The System Topology – network (connected undirected graph) Processors (nodes) Communication channels (edges) Algorithm.
Lecture 6 Template Semantics CS6133 Fall 2011 Software Specification and Verification.
SALSA: Language and Architecture for Widely Distributed Actor Systems. Carlos Varela, Abe Stephens, Department of.
Formal Model for Simulations Instructor: DR. Lê Anh Ngọc Presented by – Group 6: 1. Nguyễn Sơn Hùng 2. Lê Văn Hùng 3. Nguyễn Xuân Hậu 4. Nguyễn Xuân Tùng.
Modeling Process CSCE 668Set 14: Simulations 2 May be several algorithms (processes) runs on each processor to simulate the desired communication system.
Introduction to Formal Methods Based on Jeannette M. Wing. A Specifier's Introduction to Formal Methods. IEEE Computer, 23(9):8-24, September,
Modelling III: Asynchronous Shared Memory Model Chapter 9 by Nancy A. Lynch presented by Mark E. Miyashita.
1 Bisimulations as a Technique for State Space Reductions.
An Ontological Framework for Web Service Processes By Claus Pahl and Ronan Barrett.
C. Varela1 Chapter 5: Join Calculus Programming Distributed Computing Systems: A Foundational Approach Carlos Varela Rensselaer Polytechnic Institute.
Programming Paradigms for Concurrency Pavol Cerny Vasu Singh Thomas Wies Part III – Message Passing Concurrency.
Submodule construction in logics 1 Gregor v. Bochmann, University of Ottawa Using First-Order Logic to Reason about Submodule Construction Gregor v. Bochmann.
1 Qualitative Reasoning of Distributed Object Design Nima Kaveh & Wolfgang Emmerich Software Systems Engineering Dept. Computer Science University College.
Hop Operational Semantics
Formal Semantics of Programming Languages 虞慧群 Topic 1: Introduction.
Actors: a model of concurrent computation in Distributed Systems Amin Saremi Hamid Mohamadi.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
Time, Clocks, and the Ordering of Events in a Distributed System Leslie Lamport Massachusetts Computer Associates,Inc. Presented by Xiaofeng Xiao.
C. Varela1 Actors in SALSA and Erlang (PDCS 9, CPE 5*) Support for actor model in SALSA and Erlang Carlos Varela Rennselaer Polytechnic Institute October.
CSCI 115 Chapter 8 Topics in Graph Theory. CSCI 115 §8.1 Graphs.
C. Varela1 Distributed systems abstractions (PDCS 9, CPE 6*) Carlos Varela Rennselaer Polytechnic Institute October 20, 2015 * Concurrent Programming in.
2G1516 Formal Methods2005 Mads Dam IMIT, KTH 1 CCS: Processes and Equivalences Mads Dam Reading: Peled 8.5.
Transparent First-class Futures and Distributed Components Introduction: components, futures, and challenges Statically Representing Futures An Example.
Chapter 8 Asynchronous System Model by Mikhail Nesterenko “Distributed Algorithms” by Nancy A. Lynch.
CIS 540 Principles of Embedded Computation Spring Instructor: Rajeev Alur
From Natural Language to LTL: Difficulties Capturing Natural Language Specification in Formal Languages for Automatic Analysis Elsa L Gunter NJIT.
SystemC Semantics by Actors and Reduction Techniques in Model Checking Marjan Sirjani Formal Methods Lab, ECE Dept. University of Tehran, Iran MoCC 2008.
Agenda  Quick Review  Finish Introduction  Java Threads.
Introduction to distributed systems description relation to practice variables and communication primitives instructions states, actions and programs synchrony.
Distributed Systems Lecture 6 Global states and snapshots 1.
Chapter 2: Lambda Calculus
Carlos Varela Rennselaer Polytechnic Institute September 5, 2017
ISA 763 Security Protocol Verification
Rennselaer Polytechnic Institute
Declarative Computation Model Kernel language semantics (Non-)Suspendable statements (VRH ) Carlos Varela RPI October 11, 2007 Adapted with.
Carlos Varela Rennselaer Polytechnic Institute October 6, 2017
Concurrency control abstractions (PDCS 9, CPE 5*)
Concurrent Models of Computation
Carlos Varela Rennselaer Polytechnic Institute October 4, 2016
Declarative Computation Model Single assignment store (VRH 2
Instructor: Aaron Roth
Concurrent Programming Actors, SALSA, Coordination Abstractions
Carlos Varela Rennselaer Polytechnic Institute September 6, 2019
Presentation transcript:

C. Varela1 Chapter 4: Actors Programming Distributed Computing Systems: A Foundational Approach Carlos Varela Rensselaer Polytechnic Institute

Open Distributed Systems Addition of new components Replacement of existing components Changes in interconnections C. Varela2

Actor Configurations Model open system components: –Set of indivitually named actors –Messages “en-route” –Interface to environment: Receptionists External actors C. Varela3

Synchronous vs. Asynchronous Comminucation π-Calculus (and other process algebras such as CSS, CSP) take synchronous communication as a primitive Actors assume asynchronous communication is more primitive C. Varela4

Communication Medium In π-Calculus, channels are explicitly modelled. Multiple processes can share a channel, potentially causing intereference. In the actor model, the communication medium is not explicit. Actors (active objects) are first-class, history- sensitive entities with an explicit identity used for communication. C. Varela5

Fairness The actor model theory assumes fair computations: 1.Message delivery is guaranteed. 2.Individual actor computations are guaranteed to progress. Fairness is very useful for reasoning about equivalences of actor programs but can be hard/expensive to guarantee; in particular when distribution and failures are considered. C. Varela6

Programming Languages Influenced by П-Calculus and Actors Scheme ‘75 Act1 ‘87 Acore ‘87 Rosette ‘89 Obliq ‘94 Erlang ‘93 ABCL ‘90 SALSA ‘99 C. Varela7 Amber ’86 Facile ’89 CML ’91 Pict ’94 Nomadic Pict ’99 JOCAML ‘99

Actor (Agent) Model C. Varela8

Agha, Mason, Smith & Talcott 1.Extend a functional language (λ-calculus + ifs and pairs) with actor primitives. 2.Define an operational semantics for actor configurations. 3.Study various notions of equivalence of actor expressions and configurations. 4.Assume fairness: –Guaranteed message delivery. –Individual actor progress. C. Varela9

λ-Calculus Syntax e ::= vvalue | λv.efunctional abstraction | ( e e )application Example ( λx.x 2 2 ) x 2 {2/x} (in π-calculus) [2/x]x 2 (in λ-calculus) C. Varela10 λx.x 2 2 2

λ-Calculus pr(x,y)returns a pair containing x & y ispr(x)returns t if x is a pair; f otherwise 1 st (pr(x,y)) = xreturns the first value of a pair 2 nd (pr(x,y)) = yreturns the second value of a pair C. Varela11

Actor Primitives send(a,v) –Sends value v to actor a. new(b) –Creates a new actor with behavior b and returns the identity/name of the newly created actor. ready(b) –Becomes ready to receive a new message with behavior b. C. Varela12

Actor Language Example b5 = rec(λy. λx.seq(send(x,5), ready(y))) Receives an actor name x and sends the number 5 to that actor, then it becomes ready to process new messages with the same behavior y. Sample usage: send(new(b5), a) A Sink: sink = rec(λb. λm.ready(b)) An actor that disregards all messages. C. Varela13

Reference Cell Cell = rec(λb.λc.λm. if ( get?(m), seq( send(cust(m), c), ready(b(c))) if ( set?(m), ready(b(contents(m))), ready(b(c))))) Using the cell: Let a = new(cell(0)) in seq( send(a, mkset(7)), send(a, mkset(2)), send(a, mkget(c))) C. Varela14

Exercises 1.Write get? cust set? contents mkset mkget to complete the reference cell example in the AMST actor language. 2.Modify B cell to notify a customer when the cell value is updated (such as in the П-calculus cell example). C. Varela15

Dining Philosophers phil = rec(λb.λl.λr.λself.λsticks.λm. if (eq?(sticks, 0), ready(b(l,r,self,1)), seq( send(l,mkrelease(self)), send(r,mkrelease(self)), send(l,mkpickup(self)), send(r,mkpickup(self)), ready(b(l,r,self,0))))) C. Varela16

Dining Philosophers chopstick = rec(λb.λh.λw.λm. if(pickup?(m), if(eq?(h,nil), seq( send(getphil(m), nil), ready(b(getphil(m),nil))), ready(b(h,getphil(m))), if(release?(m), if(eq?(w,nil), ready(b(nil, nil)), seq( send(w,nil), ready(b(w,nil)))), ready(b(h,w))))) C. Varela17

Dining Philosophers letrec c1 = new(chopstick(nil,nil)), c2 = new(chopstick(nil,nil)), p1 = new(phil(c1,c2,p1,0)), p2 = new(phil(c2,c1,p2,0)) in seq( send(c1,mkpickup(p1)), send(c2,mkpickup(p1)), send(c1,mkpickup(p2)), send(c2,mkpickup(p2))) C. Varela18

Dining Philosophers Auxiliary definitions: mkpickup = λp.p mkrelease = nil pickup? = λm.not(eq?(m,nil)) release? = λm.eq?(m,nil) getphil = λm.m C. Varela19

Actor Garbage Collection C. Varela Blocked (idle) Unblocked (non-idle) Root

Join Continuations Consider: treeprod = rec(λf.λtree. if(isnat(tree), tree, f(left(tree))*f(right(tree)) )) Which multiplies all leaves of a tree, which are numbers. You can do the “left” and “right” computations concurrently. C. Varela21

Tree Product Behavior B treeprod = rec(λb.λself.λm. seq(become(b(self)), if(isnat(tree(m)), send(cust(m),tree(m)), letactor{newcust := B joincont (cust(m),0,nil)} seq(send(self, pr(left(tree(m)),newcust)), send(self, pr(right(tree(m)),newcust))) ) C. Varela22

Tree Product (continued) B joincont = rec(λb.λcust.λnargs.λfirstnum.λnum. if(eq(nargs,0), become(b(cust,1,num)), seq(become(sink), send(cust,firstnum*num)))) C. Varela23

Sample Execution C. Varela24 Cust f(tree,cust) JC Cust JC (a)(b)

Sample Execution C. Varela25 Cust JC ’ JC Cust JC firstnum (c) JC ' JC firstnum JC ' Cust firstnum JC (d)

Sample Execution C. Varela26 num Cust firstnum Cust JC (e) firstnum * num Cust (f)

Operational Semantics for Actor Configurations k = > α is a function mapping actor names (represented as variables) to actor states. µ is a multi-set of messages “en-route.” ρ is a set of receptionists. χ is a set of external actors C. Varela27 ρχρχ

Operational Semantics Given A = Dom(α): P is a subset of A, A ∩ χ is empty. If α(a) = (?a ’ ), then a ’ is in A. If a in A, then fv(α(a)) is a subset of A U χ. If in µ, then fv(v 0,v 1 ) is a subset of A U χ. C. Varela28

Operational Semantics α in X As As = (?x) U (V) U [E] µ in M w [M] M = ρ,χ in P w [X] V = At U X U λX.E U pr(V,V) E = V U app(E,E) U Fn(E n ) C. Varela29 ├

Labeled Transition Relation e e ' > > > > > >> C. Varela30 Dom(α)U{a} ρχρχ ρχρχ ρχρχ ρχρχ (where a’ is fresh) ρχρχ ρχρχ

Labeled Transition Relation, µ>> > >> > > >> C. Varela31 ρχρχ ρχρχ ρχρχ ρ'χρ'χ If v 0 is in χ and ρ ' = ρ U (fv(v 1 ) ∩ Dom(α)) ρχρχ ρχ'ρχ' If v 0 is in ρ and fv(v 1 ) ∩ Dom(α) is a subset of ρ and χ ' =χ U (fv(v 1 ) – Dom(α)

Computation Sequences and Paths If k is a configuration, then the computation tree T(k) is the set of all finite sequences of labeled transitions [k i k i+1 | i < n ] for some n in the natural numbers with k = k 0. Such sequences are called computation sequences. A computation path from k is a maximal linearly ordered set of computation sequences in the computation tree,T(k). T ∞ (k) denotes the set of all paths from k. C. Varela32 lili

A path π = [k i k i+1 | i < ] in the computation tree T ∞ (k) is fair if each enabled transition eventually happens or becomes permanently disabled. For a configuration k we define F(k) to be the subset of T ∞ (k) that are fair. Fairness C. Varela33 lili

Composition of Actor Configurations k 0 = > k 1 = > k 0 || k 1 = > Configurations are “composable” if Dom(α 0 ) ∩ Dom(α 1 ) is empty and χ 0 ∩ Dom(α 1 ) is a subset of ρ 1 χ 1 ∩ Dom(α 0 ) is a subset of ρ 0 k 0 = > C. Varela34 ρ0χ0ρ0χ0 ρ1χ1ρ1χ1 ρ 0 U ρ 1 (χ 0 U χ 1 ) – (ρ 0 U ρ 1 ) 0000

Composition of Actor Configurations (AC) k 0 || k 1 = k 1 || k 0 k 0 || k = k 0 (k 0 || k 1 ) || k 2 = k 0 || (k 1 || k 2 ) Closed Configurations: A configuration in which both the receptionist and external actor sets are empty is said to be closed Composition preserves computations paths: T(k 0 || k 1 ) = T(k 0 ) || T(k 1 ) F(k 0 || k 1 ) = F(k 0 ) || F(k 1 ) C. Varela35 0

Equivalence of Expressions Operational equivalence Testing equivalence Two program expressions are said to be equivalent if they behave the same when placed in any observing context. An observing context is a complete program with a hole, such that all free variables in expressions being evaluated become captured when placed in the hole. C. Varela36 Observational equivalence

Events and Observing Contexts A new event primitive operator is introduced. The reduction relation is extended: > > An observing configuration is on of the form: > where C is a hole-containing expression or context. C. Varela37 ρχρχ ρχρχ

Observations Let k be a configuration of the extended language and let π = [k i k i+1 | i < ] be a fair path, i.e., π is in F(k). Define: obs(π) = obs(k) = C. Varela38 lili S if there exists a, i F otherwise S if, for all π in F(k), obs(π) = s SF otherwise F if, for all π in F(k), obs(π) = s

Three Equivalences The natural equivalence is equal are made in all closing configuration contexts. Other two equivalences (weaker) arise if SF observations are considered as good as S observations; or if SF observations are considered as bad as F observations. 1.Testing or Convex or Plotkin or Egli-Milner e 0 = 1 e 1 iff Obs(O[e 0 ]) = Obs(O[e 1 ]). 1.Must or Upper or Smyth e 0 = 2 e 1 iff Obs(O[e 0 ]) = S Obs(O[e 1 ]) = S. 2.May or Lower or Hoare e 0 = 3 e 1 iff Obs(O[e 0 ]) = F Obs(O[e 1 ]) = F. C. Varela39 ~ ~ ~

Congruence e 0 = j e 1 c[e 0 ] = j c[e 1 ] for j = 1,2,3,… By construction, all equivalences defined are congruencies. Partial Collapse C. Varela40 ~~ = 1 S SF F S SF F XX X X X X = 2 S SF F S SF F = 3 S SF F S SF F (1 = 2): e 0 = 1 e 1 iff e 0 = 2 e 1 (due to fairness) (1 => 3): e 0 = 1 e 1 implies e 0 = 3 e 1 ~~ ~~ XX X XX X X X * * e0e0 e1e1