1 / 81

Actor Languages

Actor Languages. Maher Motivation Actor Actor system Bill Communication mechanism Structure of Actor languages Act’ s syntax and examples Actor-based languages Jack SALSA Mobile Agent Conclusion. Actor Languages. Maher Shinouda mshinoud@uwaterloo.ca. Objectives. Motivation

cate
Télécharger la présentation

Actor Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Actor Languages Maher • Motivation • Actor • Actor system Bill • Communication mechanism • Structure of Actor languages • Act’s syntax and examples • Actor-based languages Jack • SALSA • Mobile Agent • Conclusion

  2. Actor Languages Maher Shinouda mshinoud@uwaterloo.ca

  3. Objectives • Motivation • Brief history • What are actors • Characteristics of actor-based languages • Actor communication • Events in actor languages • Actor system • Actor’s behavior • Simple Example • Actors VS Linda

  4. Motivation • Develop language for concurrency “Parallel Execution of actions”. Concurrency in distributed systems exhibits: • Divergence • Deadlock • Mutual Exclusion

  5. Brief History • A number of individuals have contributed to the development of the actor model. • Actor model was first described by Carl Hewitt (70’s) • The model was object-oriented: every object was a computationally active entity capable of receiving and reacting to messages. The Objects were called Actors. • Gul Agha, later develop the actor model and develop a mathematical theory of actors. • Actor languages can all trace its ancestor either directly or indirectly to Lisp.

  6. What are Actors Actors are independent concurrent objects that interact by sending asynchronous messages; each actor has its mail address and a behavior. An actor can do the following: • Send communication to other actors. • Create new actors. • Define a new behaviour for itself, which may be the same or different to its previous behaviour.

  7. Three actions an actor may perform

  8. What are Actors • Anatomy of Actor

  9. Characteristics of Actor-based language • Encapsulation • All procedures and declarative information are encapsulated into a single entity “Actor”. • Actors share the main characteristics of objects in Simula and Smalltalk. • Actors considered to be Autonomous objects.

  10. Characteristics of Actor-based language (Cont.) • Inheritance • In OOP, Each object is related to a class and further more the class may be an object belonging to meta-class. • The notion of class is not integral to the actor model. • Inheritance in actors provide a conceptual organization of the system which is dynamically reconfigurable.

  11. Characteristics of Actor-based language (Cont.) Delegation • Sub-computation can be passed on by an actor to another actor which continue the processing. • Delegation promote modularity of the code. Concurrency • Actor language allow actors to specify a replacement which has 2 implications: • Capture history-sensitive information. • Allow for concurrent execution of expressions that don’t involve data dependency.

  12. Actor Communication • Actor communicate using message passing only. • All communication is asynchronous. • Each Actor has mail address with mail queue. An actor may know the mail address because: • It has always know the address. • It received the address within a communication from another actor. • It created the address as part of creating another actor.

  13. Actor communication (cont.) A message (Task) is represented as 3 tuples: 1- A tag which distinguish it from other tasks in the system. 2- A target which is the mail address to which the communication is to be delivered. 3- A communication which contain information which made available to the actor at the target.

  14. Actor Actor = Component • An actor is a special type of object that: Communicates with other actors by sending and receiving data via the mail address. • No shared state between actors. An actor may be described by specifying: • Its mail address with sufficiently large mail queue. • Behavior, which is a function of the communication accepted.

  15. Event • What is event? An event cause a communication to be sent; or represent the processing of the communication. • Arrival order of events is nondeterministic. • Actor computation may be represented by event diagram.

  16. Event Diagram

  17. A C B Actor System Group of actors within it and the set of tasks to be carried out. Two types of special actors needed: • A receptionist: An actor which may receive communication from outside the system. • An external actor: Is one which is not in the system but its address is known to one or more actors within the system, allowing them to send communication.

  18. The basic constructs A program in an actor language consists of: • behavior definitions:which simply associate a behavior schema with an identifier. • new expressions: which create actors. • Send commands: which create tasks.

  19. The basic constructs (cont.) • A receptionist declaration: which lists actors that may receive communications from the outside. • An external declaration: which lists actors that are not part of the system but to whom communications may be sent from the system.

  20. Actor’s behavior The behavior of actor consists of three kind of actions: • Create actors with specified behavior. <new expression>::= new<beh name> ({expr{, expr}*}) • Send message asynchronously to specified actor. <send command> ::= send<communication> to <target> • Become a new actor, assuming a new behavior to respond to the next message. become <expression>

  21. Actor System (cont.) Two important facts about mail system in the actor system: • Mail arrives in random, non deterministic order (asynchronous). Ensures concurrent execution. • The mail delivery is guaranteed. The system guarantee to execute all tasks eventually.

  22. Simple Example actor AdderAndMutlipy (Double k) Double A, Double B ==> Double C: action [a], [b] ==> [c] with Double c: c:=k*(a+b): endaction endactor

  23. Another Example actor AdderAndMutlipy2[T] (T k) T A, T B ==> T C: action [a], [b] ==> [k*(a+b)]: endaction action [a], [] ==> [k*a]: endaction action [], [b] ==> [k*b]: endaction endactor

  24. Provide point-to-point communication and object-style encapsulation. The locality property in actor: there is no way for an actor to contact other actors whose name hasn’t received in a previous communication. Actors are components. Provide pattern directed invocation Decoupled in both space and time: Information may be available so that any one can potentially access it. Linda doesn’t include the notion of component directly; nevertheless, the Tuple Space that it defines can be viewed as a generic connection component. Actors VS Linda

  25. Manifold • Inter-process communication in MANIFOLD is asynchronous, using broadcast of events and a dynamic data-flow.

  26. Actor Languages • Communication mechanisms • Structure of Actor Languages • Kernel language Act • Actor-based languages Lehui (Bill) Nie @ UW

  27. Communication mechanisms • Actors are active objects which communicate by message passing • Asynchronous buffered communication • It's hard to imagine a reasonable system built on asynchronous, unbuffered communication. Too much would get lost.

  28. Communication mechanisms • Communication is asynchronous, without any guaranteed arrival order. • Message order: if actor A sends a sequence of communications to actor B, then B may not receive them in the same order that A sent them. • It is possible for A to tag each message with a sequence number, so that B may rearrange messages into the correct order.

  29. Communication mechanisms • Shared variables are not allowed in the actor model. • Shared variables means that they provide data transfer without any coordination mechanism or concurrency control. Variables sharing further complicates distribution and synchronization. • Latency and timing issues make it awkward to use shared variables in an asynchronous environment.

  30. The Structure of Actor Languages

  31. Control structure: recursive factorial computation • When actor factorial receives • 3 and mail address c, it creates a • new actor m, and sends itself the • request to evaluate the factorial • of 2 • When actor m receives a • result, m multiplies 3 and the result • and send to c • There is nothing inherently • concurrent in the recursive algorithm • to evaluate a factorial.

  32. Comparison • Sequential language • Using a stack of activations. • No mechanism for distributing the work of computing a factorial or concurrently processing more than one request. • Actor-based language • Creating actors which waits for the appropriate communications. They are free to concurrently process the next communication. • Delegating most of the processing to a large number of actors. • Given a network of processors, an actor-based language could process a large number of requests much faster by simply distributing the actors it creates among these processors.

  33. Join continuations: tree product • Divide and conquer concurrency can often be naturally expressed by using a functional form which evaluates its arguments concurrently. • Join continuation is used to synchronize the evaluation of the different arguments.

  34. Tree product event diagram

  35. Language Act • Act is a sufficient kernel for Act3 • Syntax • <act program> ::= <behavior definition>* (<command>*) • <behavior definition> ::= (define (id {(with identifier <pattern>)}*) <communication handler>*) • <communication handler> ::= (Is-communication <pattern> do <command>*)

  36. Language Act • <command> ::= <let command> | <conditional command> | <send command> | <become command> • <let command> ::= (let (<let binding>*) do <command>*) • <conditional command> ::= (if <expression> (then do <command>*) (else do <command>*)) • <send command> ::= (send <expression> <expression>) • <become command> ::= (become <expression>)

  37. Example: Factorial c

  38. Actor-based languages

  39. Actor-based languages

  40. Actor-Based Concurrent Language(ABCL) • Message sending order from one object to another is preserved in ABCL. • Three types of message passing mechanisms • Past Non-blocking messages without a reply • Now Blocking messages with sender waiting for a reply • Future Non-blocking messages with a reply expected in the future

  41. Concurrent Aggregates (CA) • Extends the Actor model with inheritance and aggregates • An aggregate is a group of actors of the same kind. All constituent actors share the same name. • A message sent to the aggregates is processed by one and only one constituent but which constituent receives the message is left unspecified (i.e., one-to-one-of-many type of communication). • Unlike the Actor model, every message send in CA expects a reply by default.

  42. Rosette • The most commercially successful actor-based language up to now • Used as a language for the interpreter of the extensible services switch in the Carnot project at Microelectronics and Computer Technology Corporation (MCC) • Continues to be used to provide heterogeneous interoperability for middleware in intranet and enterprise integration software • With Rosette, the object-oriented programming model and the concurrent execution model are combined to simplify the development of autonomous, distributed agents.

  43. Active Object • Passive object oriented language • Separation of state (procedure and data) and thread manipulating that state • Active object oriented language • Encapsulation of state and thread • More appropriate for implementing concurrent and distributed systems

  44. Actor Languages SALSA Mobile Agents What are Aglets? Conclusions Questions? Jack Chi@UW

  45. Execution environment

  46. Execution environment (cont.) • The execution environment Application running on the Internet, or on limited-resource devices, need to adapt to changes in their execution environment at run-time. eg. db2 get dbm cfg db2 get db cfg

  47. Problem • Current languages and systems fall short of enabling developers to migrate and reconfigure application sub-components at program-execution time. • Concurrent execution environment.

  48. SALSA • Simple Actor Language, System and Architecture • Features: • Simplifies programming dynamically reconfigurable. Open application by providing universal name, active objects and migration. • Token-passing continuations, join continuations and first-class continuations.

  49. Requirements • Internet and mobile computing place new demands on applications, which require them to be open and dynamically reconfigurable. • Java is popular today. • However, higher-level programming languages are required, in order for applications to be reconfigured, migrate to other platforms, and decomposed and re-composed arbitrarily.

  50. SALSA • SALSA program can be easily preprocessed to Java and preserve Java’s useful object-oriented concepts.

More Related