ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.
-
Upload
julianna-morgan -
Category
Documents
-
view
214 -
download
0
Transcript of ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.
![Page 1: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/1.jpg)
ACTORS
![Page 2: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/2.jpg)
Motivation
Develop language for concurrency “Parallel Execution of actions”.
![Page 3: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/3.jpg)
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.
![Page 4: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/4.jpg)
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 behavior for itself, which may be the same or
different to its previous behavior.
![Page 5: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/5.jpg)
Behavior change
Higher level than state change (assignment)
The current behavior of an actor will specify its replacement behavior
– How it will perform the next incoming message
A behavior accepts only one message
A causally connected chain of behaviors isomorphic to the queue of messages
![Page 6: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/6.jpg)
![Page 7: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/7.jpg)
Mail System
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 guarantees to execute all tasks eventually.
![Page 8: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/8.jpg)
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.
![Page 9: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/9.jpg)
Extending the Actalk framework towards ACTORS
ActorBehavior subclass: #AghaActorBehavior
setProcess
[self acceptNextMessage] fork
replace: replacementBehavior
aself initializeBehavior: replacementBehavior
![Page 10: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/10.jpg)
Example
AghaActorBehavior subclass: #AghaCounter
instanceVariables: ‘contents’
consultAndReplyTo: replyDestination
self replace: (self class contents: contents).
replyDestination reply: contents
incr
self replace: (self class contents: contents + 1)
reset
self replace: (self class contents: 0)
![Page 11: ACTORS. Motivation Develop language for concurrency “ Parallel Execution of actions ”.](https://reader036.fdocuments.us/reader036/viewer/2022082821/5697c0271a28abf838cd6212/html5/thumbnails/11.jpg)
References
Agha, Gul, Actors: A Model of Concurrent Computation in Distributed Systems. MIT Press, 1986, 144 p.
Open Systems Laboratory– http://osl.cs.uiuc.edu/