Santa Claus with Mobile with Mobile Santa Claus with Mobile - - PowerPoint PPT Presentation

santa claus with mobile with mobile santa claus with
SMART_READER_LITE
LIVE PREVIEW

Santa Claus with Mobile with Mobile Santa Claus with Mobile - - PowerPoint PPT Presentation

Santa Claus with Mobile with Mobile Santa Claus with Mobile Santa Claus Reindeer and Elves Reindeer and Elves Reindeer and Elves Peter Welch ( phw@kent.ac.uk ) Matt Pedersen ( matt@faculty.egr.unlv.edu ) CPA 2008 (09/07/2008)


slide-1
SLIDE 1

Santa Claus – with Mobile Reindeer and Elves Santa Claus Santa Claus – – with Mobile with Mobile Reindeer and Elves Reindeer and Elves

CPA 2008 (09/07/2008) Peter Welch (phw@kent.ac.uk) Matt Pedersen (matt@faculty.egr.unlv.edu)

slide-2
SLIDE 2

MOBILE MOBILE processes

processes … … Santa Claus Santa Claus … …

slide-3
SLIDE 3

A B D E C P Q S T R

An occam

  • ccam-
  • π

π mobile process, embedded anywhere in a dynamically evolving network, may suspend suspend itself mid- execution, be safely disconnected disconnected from its local environment, moved moved (by channel communication) to a new environment, reconnected reconnected to that new environment and reactivated reactivated.

Mobile Process Types Mobile Mobile Process Process Types Types

slide-4
SLIDE 4

An occam

  • ccam-
  • π

π mobile process, embedded anywhere in a dynamically evolving network, may suspend suspend itself mid- execution, be safely disconnected disconnected from its local environment, moved moved (by channel communication) to a new environment, reconnected reconnected to that new environment and reactivated reactivated.

A B D E C P Q S T R

Mobile Process Types Mobile Mobile Process Process Types Types

slide-5
SLIDE 5

An occam

  • ccam-
  • π

π mobile process, embedded anywhere in a dynamically evolving network, may suspend suspend itself mid- execution, be safely disconnected disconnected from its local environment, moved moved (by channel communication) to a new environment, reconnected reconnected to that new environment and reactivated reactivated.

A B D E C P Q S T R

Mobile Process Types Mobile Mobile Process Process Types Types

slide-6
SLIDE 6

An occam

  • ccam-
  • π

π mobile process, embedded anywhere in a dynamically evolving network, may suspend suspend itself mid- execution, be safely disconnected disconnected from its local environment, moved moved (by channel communication) to a new environment, reconnected reconnected to that new environment and reactivated reactivated.

A B D E C P Q S T R

Mobile Process Types Mobile Mobile Process Process Types Types

slide-7
SLIDE 7

An occam

  • ccam-
  • π

π mobile process, embedded anywhere in a dynamically evolving network, may suspend suspend itself mid- execution, be safely disconnected disconnected from its local environment, moved moved (by channel communication) to a new environment, reconnected reconnected to that new environment and reactivated reactivated. Upon reactivation, the process resumes from the same state (i.e. data values and code positions) (i.e. data values and code positions) it held when suspended. Its view of that environment is unchanged, since that is abstracted by its channel since that is abstracted by its channel interface

  • interface. The environment on the other side of that

abstraction, however, will usually be different. The mobile process may itself contain any number of any number of levels levels of dynamically evolving parallel sub-network.

Mobile Process Types Mobile Mobile Process Process Types Types

slide-8
SLIDE 8

Mobile processes are entities encapsulating state and

  • code. They may be active

active or passive

  • passive. Initially, they

are passive passive. The state of a mobile process can only be felt by interacting with it when active

  • active. When passive

passive, its state is locked – even against reading. passive passive active active

activate (self) suspend move

Mobile Process Types Mobile Mobile Process Process Types Types

slide-9
SLIDE 9

When passive passive, they may be activated activated or moved

  • moved. A

moved moved process remains passive

  • passive. An active

active process cannot be moved moved or activated activated in parallel. When an active active mobile process suspends suspends, it becomes passive passive – retaining its state and code position. When it moves, its state moves with it. When re-activated activated, it sees its previous state and continues from where it left off. passive passive active active

activate (self) suspend move

Mobile Process Types Mobile Mobile Process Process Types Types

slide-10
SLIDE 10

Mobile processes exist in many technologies – such as applets applets, agents agents and in distributed operating systems.

  • ccam
  • ccam-
  • π

π offers (will offer) support for them with a formal denotational denotational and refinement refinement semantics, safety and very low overheads. Process mobility semantics follows naturally from that for mobile data and mobile channel-ends. We need to introduce a concept of process types types and variables variables.

Mobile Process Types Mobile Mobile Process Process Types Types

slide-11
SLIDE 11

PROC TYPE PROC TYPE IN.OUT.SUSPEND IN.OUT.SUSPEND (CHAN INT (CHAN INT in in?, ?, out

  • ut!,

!, suspend suspend?): ?):

Process type type declarations give names to PROC

PROC header

  • templates. Mobile processes may implement types

with synchronisation parameters only (i.e. channels, barriers, buckets, etc.) plus records and fixed-size arrays of the same. For example: The above declares a process type type called IN.OUT.SUSPEND

IN.OUT.SUSPEND.

Processes implementing this will be given three channels by the (re-)activating host process: two for input (in

in?, ?, suspend suspend? ?)

and one for output (out

  • ut!

!), all carrying INT INT traffic.

Process types types are used in two ways: for the declaration

  • f process variables

variables and to define the connection connection interface interface to a mobile process.

Mobile Process Types Mobile Mobile Process Process Types Types

slide-12
SLIDE 12

Mobile Process Example Mobile Mobile Process Process Example Example

WHILE TRUE WHILE TRUE INT INT x x: : PRI ALT PRI ALT suspend suspend ? ? x x in in ? ? x x SEQ SEQ total total := := total total + + x x

  • ut
  • ut !

! total total INITIAL INT INITIAL INT total total IS 0: IS 0: --

  • - local state

local state SUSPEND SUSPEND

  • - control returns to activator

control returns to activator

  • - control resumes here when next activated

control resumes here when next activated MOBILE MOBILE PROC PROC integrate.suspend integrate.suspend (CHAN INT (CHAN INT in in?, ?, out

  • ut!,

!, suspend suspend?) ?) : : suspend in

  • ut

integrate.suspend integrate.suspend

IMPLEMENTS IMPLEMENTS IN.OUT.SUSPEND IN.OUT.SUSPEND

slide-13
SLIDE 13

Mobile Processes and Types Mobile Processes Mobile Processes and and Types Types

A process type type may be implemented by many mobile processes – each offering different behaviours. A process variable variable has a specific process type. Its value may be undefined undefined or some mobile process some mobile process implementing its type. A process variable may be bound to different mobile processes, offering different behaviours, at different times in its life. When defined defined, it can only be activated according to that type. The mobile process from the last slide, integrate.suspend

integrate.suspend,

implements the process type, IN.OUT.SUSPEND

IN.OUT.SUSPEND, defined

  • earlier. Other processes could implement the same type.
slide-14
SLIDE 14

process.out process.out ! ! p p

  • - p

p is now undefined (can is now undefined (can’ ’t move or activate it) t move or activate it) PROC PROC A A (CHAN (CHAN IN.OUT.SUSPEND IN.OUT.SUSPEND process.out process.out!) !) : : p p := := MOBILE MOBILE integrate.suspend integrate.suspend

  • - p

p is now defined (can move and activate) is now defined (can move and activate) IN.OUT.SUSPEND IN.OUT.SUSPEND p p: : SEQ SEQ

  • - p

p is not yet defined (can is not yet defined (can’ ’t move or activate it) t move or activate it) process.out process.out

A A

Mobile Process Example Mobile Mobile Process Process Example Example

slide-15
SLIDE 15

PROC PROC B B (CHAN (CHAN IN.OUT.SUSPEND IN.OUT.SUSPEND process.in process.in? ?, , process.out process.out!, !, CHAN INT CHAN INT in in?, ?, out

  • ut!,

!, suspend suspend?) ?) : : WHILE TRUE WHILE TRUE IN.OUT.SUSPEND IN.OUT.SUSPEND q q: : SEQ SEQ ... input a process to ... input a process to q q ... plug into local channels and activate ... plug into local channels and activate q q ... when finished, send it on its way ... when finished, send it on its way process.in process.in

B B

process.out process.out in in suspend suspend

  • ut
  • ut

Mobile Process Example Mobile Mobile Process Process Example Example

slide-16
SLIDE 16

process.out process.out ! ! q q

  • - q is now undefined (can

q is now undefined (can’ ’t move or activate it) t move or activate it) process.in process.in ? ? q q

  • - q is now defined (can move and activate)

q is now defined (can move and activate) WHILE TRUE WHILE TRUE IN.OUT.SUSPEND IN.OUT.SUSPEND q q: : SEQ SEQ

  • - q is not yet defined (can

q is not yet defined (can’ ’t move or activate it) t move or activate it) q (in?, out!, suspend?) q (in?, out!, suspend?)

  • - q is still defined (can move and activate)

q is still defined (can move and activate) process.in process.in

B B

process.out process.out in in suspend suspend

  • ut
  • ut

Mobile Process Example Mobile Mobile Process Process Example Example

slide-17
SLIDE 17

Mobile Process Example Mobile Mobile Process Process Example Example

CHAN CHAN IN.OUT.SUSPEND IN.OUT.SUSPEND c c, , d d: : CHAN INT CHAN INT in in, , out

  • ut,

, suspend suspend: : ... other channels ... other channels PAR PAR A A ( (c c!) !) B B ( (c c?, ?, d d!, !, in in?, ?, out

  • ut!,

!, suspend suspend?) ?) ... other processes ... other processes

… …

c c in in

  • ut
  • ut

suspend suspend

B B

d d

A A

slide-18
SLIDE 18

MOBILE MOBILE processes

processes … … Santa Claus Santa Claus … …

slide-19
SLIDE 19

Santa repeatedly sleeps until wakened by either all of his nine reindeer (back from their holidays) or by a group of three of his ten elves (who have left their workbenches). Santa repeatedly sleeps until wakened by either Santa repeatedly sleeps until wakened by either all all of his

  • f his

nine nine reindeer (back from their holidays) or by a group of reindeer (back from their holidays) or by a group of three three of his

  • f his ten

ten elves (who have left their workbenches). elves (who have left their workbenches). If awakened by the reindeer, he harnesses each of them to his sleigh, delivers toys with them and finally unharnesses them (allowing them to go back on holiday). If awakened by the reindeer, If awakened by the reindeer, he harnesses each of them to he harnesses each of them to his sleigh, delivers toys with them and finally his sleigh, delivers toys with them and finally unharnesses unharnesses them (allowing them to go back on holiday). them (allowing them to go back on holiday). If awakened by a group of elves, he shows each of the group into his study, consults with them on toy R&D and finally shows each of them out (allowing them to go back to work). If awakened by a group of elves, If awakened by a group of elves, he shows each of the he shows each of the group into his study, consults with them on toy R&D and group into his study, consults with them on toy R&D and finally shows each of them out (allowing them to go back finally shows each of them out (allowing them to go back to work). to work). Santa should give priority to the reindeer in the case that there is both a group of elves and a group of reindeer waiting. Santa should give priority to the reindeer Santa should give priority to the reindeer in the case that in the case that there is both a group of elves and a group of reindeer there is both a group of elves and a group of reindeer waiting. waiting.

J.A.Trono, “A new exercise in concurrency”, SIGCSE Bulletin 26(3), pp. 8-10, 1994. J.A.Trono J.A.Trono, , “ “A new exercise in concurrency A new exercise in concurrency” ”, , SIGCSE Bulletin 26(3), pp. 8 SIGCSE Bulletin 26(3), pp. 8-

  • 10, 1994.

10, 1994.

slide-20
SLIDE 20

First: a static network (classical

  • ccam, shared channels, barriers

and partial barriers) First: a static network (classical First: a static network (classical

  • ccam, shared channels, barriers
  • ccam, shared channels, barriers

and partial barriers) and partial barriers)

slide-21
SLIDE 21

santa.reindeer santa.reindeer reindeer.2.santa reindeer.2.santa report report

Santa Santa

just.reindeer just.reindeer Reindeer (0) Reindeer (0) Reindeer (1) Reindeer (1) Reindeer (8) Reindeer (8)

... ...

slide-22
SLIDE 22

report report

... ...

Elf (0) Elf (0) Elf (1) Elf (1) Elf (9) Elf (9)

Santa Santa

santa.elves santa.elves (4) (4) elves.2.santa elves.2.santa just.elves just.elves (3) (3)

slide-23
SLIDE 23

santa.reindeer santa.reindeer reindeer.2.santa reindeer.2.santa report report

Santa Santa

just.reindeer just.reindeer Reindeer (0) Reindeer (0) Reindeer (1) Reindeer (1) Reindeer (8) Reindeer (8)

... ...

slide-24
SLIDE 24

report report

... ...

Elf (0) Elf (0) Elf (1) Elf (1) Elf (9) Elf (9)

Santa Santa

santa.elves santa.elves (4) (4) elves.2.santa elves.2.santa just.elves just.elves (3) (3)

slide-25
SLIDE 25

report report santa.elves.b santa.elves.b elves.2.santa elves.2.santa just.elves.b just.elves.b

p.bar (4) xp.bar (3)

santa.elves.a santa.elves.a just.elves.a just.elves.a

... ...

Elf (0) Elf (0) Elf (1) Elf (1) Elf (9) Elf (9)

Santa Santa

slide-26
SLIDE 26

Second: a dynamic network (mobile channels) Second: a dynamic network (mobile Second: a dynamic network (mobile channels) channels)

Deferred … (ask Adam!) Deferred Deferred … … (ask Adam!) (ask Adam!)

slide-27
SLIDE 27

Third: a dynamic network (mobile processes) Third: a dynamic network (mobile Third: a dynamic network (mobile processes) processes)

slide-28
SLIDE 28

compound ( compound (n.reindeer n.reindeer) ) gather ( gather (n.reindeer n.reindeer) ) santa santa’ ’s s grotto grotto compound ( compound (n.elves n.elves) ) gather ( gather (g.elves g.elves) ) r.knock r.knock e.knock e.knock report report report report report report report report report report

r r e e i i n n d d e e e e r r e e l l v v e e s s

slide-29
SLIDE 29

compound (n) compound (n) report report station station station station station station

... ...

slide-30
SLIDE 30

PROC station (VAL INT id, seed, kind, away.time, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT agent: SEQ agent := MOBILE reindelf ... initialise agent ... loop (send agent; receive agent; run agent) : PROC station (VAL INT id, seed, kind, PROC station (VAL INT id, seed, kind, away.time away.time, , SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT MOBILE AGENT agent agent: : SEQ SEQ agent := MOBILE agent := MOBILE reindelf reindelf ... initialise agent ... initialise agent ... loop (send agent; receive agent; run agent) ... loop (send agent; receive agent; run agent) : :

report report station station in in

  • ut
  • ut

report report A reindelf : either a reindeer or an elf A A reindelf reindelf : either a reindeer or an elf : either a reindeer or an elf

slide-31
SLIDE 31

report report station station in in

  • ut
  • ut

{{{ initialise agent CHAN AGENT.INITIALISE initialise: ... some dummy channels PAR initialise ! id; seed; kind; away.time agent (initialise?, report!, ...) }}} {{{ initialise agent {{{ initialise agent CHAN AGENT.INITIALISE initialise: CHAN AGENT.INITIALISE initialise: ... some dummy channels ... some dummy channels PAR PAR initialise ! id; seed; kind; initialise ! id; seed; kind; away.time away.time agent (initialise?, report!, agent (initialise?, report!, ... ...) ) }}} }}}

report report A reindelf : either a reindeer or an elf A A reindelf reindelf : either a reindeer or an elf : either a reindeer or an elf initialise initialise

slide-32
SLIDE 32

report report station station in in

  • ut
  • ut

initialise initialise report report A reindelf : either a reindeer or an elf A A reindelf reindelf : either a reindeer or an elf : either a reindeer or an elf

PROC station (VAL INT id, seed, kind, away.time, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT agent: SEQ agent := MOBILE reindelf ... initialise agent ... loop (send agent; receive agent; run agent) : PROC station (VAL INT id, seed, kind, PROC station (VAL INT id, seed, kind, away.time away.time, , SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT MOBILE AGENT agent agent: : SEQ SEQ agent := MOBILE agent := MOBILE reindelf reindelf ... initialise agent ... initialise agent ... loop (send agent; receive agent; run agent) ... loop (send agent; receive agent; run agent) : :

slide-33
SLIDE 33

{{{ loop (send agent; receive agent; run agent) WHILE TRUE SEQ CLAIM out ! agent CLAIM in ? agent CHAN AGENT.INITIALISE dummy.init: ... more dummy channels agent (dummy.init?, report!, ...) }}} {{{ loop (send agent; receive agent; run agent) {{{ loop (send agent; receive agent; run agent) WHILE TRUE WHILE TRUE SEQ SEQ CLAIM out ! agent CLAIM out ! agent CLAIM in ? agent CLAIM in ? agent CHAN AGENT.INITIALISE CHAN AGENT.INITIALISE dummy.init dummy.init: : ... more dummy channels ... more dummy channels agent ( agent (dummy.init dummy.init?, report!, ...) ?, report!, ...) }}} }}}

report report station station in in

  • ut
  • ut

initialise initialise report report A reindelf : either a reindeer or an elf A A reindelf reindelf : either a reindeer or an elf : either a reindeer or an elf

slide-34
SLIDE 34

report report station station in in

  • ut
  • ut

PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, ... ): PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, ... ... ): ):

report report initialise initialise reindelf (an agent) reindelf reindelf (an agent) (an agent)

{{{ loop (send agent; receive agent; run agent) WHILE TRUE SEQ CLAIM out ! agent CLAIM in ? agent CHAN AGENT.INITIALISE dummy.init: ... more dummy channels agent (dummy.init?, report!, ...) }}} {{{ loop (send agent; receive agent; run agent) {{{ loop (send agent; receive agent; run agent) WHILE TRUE WHILE TRUE SEQ SEQ CLAIM out ! agent CLAIM out ! agent CLAIM in ? agent CLAIM in ? agent CHAN AGENT.INITIALISE CHAN AGENT.INITIALISE dummy.init dummy.init: : ... more dummy channels ... more dummy channels agent ( agent (dummy.init dummy.init?, report!, ...) ?, report!, ...) }}} }}}

slide-35
SLIDE 35

PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, ... ): PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, ... ... ): ): MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, ... ) IMPLEMENTS AGENT INT id, seed, kind, away.time: SEQ initialise ? id; seed; kind; away.time WHILE TRUE SEQ CLAIM report ! away; kind; id ... away time (random delay up to away.time) CLAIM report ! ready; kind; id SUSPEND -- move to gathering place ... SUSPEND

  • - move to santa’s grotto

... SUSPEND -- move to compound : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, ... ... ) ) IMPLEMENTS AGENT IMPLEMENTS AGENT INT id, seed, kind, INT id, seed, kind, away.time away.time: : SEQ SEQ initialise ? id; seed; kind; initialise ? id; seed; kind; away.time away.time WHILE TRUE WHILE TRUE SEQ SEQ CLAIM report ! away; kind; id CLAIM report ! away; kind; id ... away time (random delay up to ... away time (random delay up to away.time away.time) ) CLAIM report ! ready; kind; id CLAIM report ! ready; kind; id SUSPEND SUSPEND --

  • - move to gathering place

move to gathering place ... ... SUSPEND SUSPEND

  • - move to

move to santa santa’ ’s s grotto grotto ... ... SUSPEND SUSPEND --

  • - move to compound

move to compound : :

slide-36
SLIDE 36

MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, ... ) IMPLEMENTS AGENT INT id, seed, kind, away.time: SEQ initialise ? id; seed; kind; away.time WHILE TRUE SEQ CLAIM report ! away; kind; id ... away time (random delay up to away.time) CLAIM report ! ready; kind; id SUSPEND -- move to gathering place ... SUSPEND

  • - move to santa’s grotto

... SUSPEND -- move to compound : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, ... ... ) ) IMPLEMENTS AGENT IMPLEMENTS AGENT INT id, seed, kind, INT id, seed, kind, away.time away.time: : SEQ SEQ initialise ? id; seed; kind; initialise ? id; seed; kind; away.time away.time WHILE TRUE WHILE TRUE SEQ SEQ CLAIM report ! away; kind; id CLAIM report ! away; kind; id ... away time (random delay up to ... away time (random delay up to away.time away.time) ) CLAIM report ! ready; kind; id CLAIM report ! ready; kind; id SUSPEND SUSPEND --

  • - move to gathering place

move to gathering place ... ... SUSPEND SUSPEND

  • - move to

move to santa santa’ ’s s grotto grotto ... ... SUSPEND SUSPEND --

  • - move to compound

move to compound : :

report report initialise initialise

slide-37
SLIDE 37

report report station station in in

  • ut
  • ut

initialise initialise report report A reindelf : either a reindeer or an elf A A reindelf reindelf : either a reindeer or an elf : either a reindeer or an elf

PROC station (VAL INT id, seed, kind, away.time, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT agent: SEQ agent := MOBILE reindelf ... initialise agent ... loop (send agent; receive agent; run agent) : PROC station (VAL INT id, seed, kind, PROC station (VAL INT id, seed, kind, away.time away.time, , SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!) SHARED CHAN AGENT.MESSAGE report!) MOBILE AGENT MOBILE AGENT agent agent: : SEQ SEQ agent := MOBILE agent := MOBILE reindelf reindelf ... initialise agent ... initialise agent ... loop (send agent; receive agent; run agent) ... loop (send agent; receive agent; run agent) : :

slide-38
SLIDE 38

compound (n) compound (n) report report station station station station station station

... ...

slide-39
SLIDE 39

compound ( compound (n.reindeer n.reindeer) ) gather ( gather (n.reindeer n.reindeer) ) santa santa’ ’s s grotto grotto compound ( compound (n.elves n.elves) ) gather ( gather (g.elves g.elves) ) r.knock r.knock e.knock e.knock report report report report report report report report report report

r r e e i i n n d d e e e e r r e e l l v v e e s s

slide-40
SLIDE 40

gather (n) gather (n) knock knock report report in in

  • ut
  • ut

PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, CHAN BOOL knock!) WHILE TRUE [n]MOBILE AGENT agent: SEQ SEQ i = 0 FOR n SEQ in ? agent[i] ... plug in agent (let it make brief report) knock ! TRUE -- knock on santa’s door SEQ i = 0 FOR n

  • ut ! agent[i]

knock ! TRUE -- wait for door to slam : PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, CHAN BOOL knock!) CHAN BOOL knock!) WHILE TRUE WHILE TRUE [ [n]MOBILE n]MOBILE AGENT AGENT agent agent: : SEQ SEQ SEQ SEQ i = 0 FOR n i = 0 FOR n SEQ SEQ in ? in ? agent[i agent[i] ] ... plug in agent (let it make brief report) ... plug in agent (let it make brief report) knock ! TRUE knock ! TRUE --

  • - knock on

knock on santa santa’ ’s s door door SEQ i = 0 FOR n SEQ i = 0 FOR n

  • ut !
  • ut ! agent[i

agent[i] ] knock ! TRUE knock ! TRUE --

  • - wait for door to slam

wait for door to slam : :

report report initialise initialise

slide-41
SLIDE 41

gather (n) gather (n) knock knock report report in in

  • ut
  • ut

{{{ plug in agent (let it make brief report) CHAN AGENT.INITIALISE dummy.init: ... more dummy channels agent[i] (dummy.init?, report!, ...) }}} {{{ plug in agent (let it make brief report) {{{ plug in agent (let it make brief report) CHAN AGENT.INITIALISE CHAN AGENT.INITIALISE dummy.init dummy.init: : ... more dummy channels ... more dummy channels agent[i agent[i] ( ] (dummy.init dummy.init?, report!, ...) ?, report!, ...) }}} }}}

report report initialise initialise

slide-42
SLIDE 42

gather (n) gather (n) knock knock report report in in

  • ut
  • ut

MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, ... ) IMPLEMENTS AGENT ... local state declarations SEQ ... in station compound (initialise local state) WHILE TRUE SEQ ... in station compound SUSPEND -- move to gathering place CLAIM report ! waiting; kind; id SUSPEND -- move to santa’s grotto ... in santa’s grotto SUSPEND -- move to compound : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, ... ... ) ) IMPLEMENTS AGENT IMPLEMENTS AGENT ... local state declarations ... local state declarations SEQ SEQ ... in station compound (initialise local state) ... in station compound (initialise local state) WHILE TRUE WHILE TRUE SEQ SEQ ... in station compound ... in station compound SUSPEND SUSPEND --

  • - move to gathering place

move to gathering place CLAIM report ! waiting; kind; id CLAIM report ! waiting; kind; id SUSPEND SUSPEND --

  • - move to

move to santa santa’ ’s s grotto grotto ... in ... in santa santa’ ’s s grotto grotto SUSPEND SUSPEND --

  • - move to compound

move to compound : :

report report initialise initialise

slide-43
SLIDE 43

gather (n) gather (n) knock knock report report in in

  • ut
  • ut

report report initialise initialise

PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, CHAN BOOL knock!) WHILE TRUE [n]MOBILE AGENT agent: SEQ SEQ i = 0 FOR n SEQ in ? agent[i] ... plug in agent (let it make brief report) knock ! TRUE -- knock on santa’s door SEQ i = 0 FOR n

  • ut ! agent[i]

knock ! TRUE -- wait for door to slam : PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, PROC gather (VAL INT n, CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, CHAN BOOL knock!) CHAN BOOL knock!) WHILE TRUE WHILE TRUE [ [n]MOBILE n]MOBILE AGENT AGENT agent agent: : SEQ SEQ SEQ SEQ i = 0 FOR n i = 0 FOR n SEQ SEQ in ? in ? agent[i agent[i] ] ... plug in agent (let it make brief report) ... plug in agent (let it make brief report) knock ! TRUE knock ! TRUE --

  • - knock on

knock on santa santa’ ’s s door door SEQ i = 0 FOR n SEQ i = 0 FOR n

  • ut !
  • ut ! agent[i

agent[i] ] knock ! TRUE knock ! TRUE --

  • - wait for door to slam

wait for door to slam : :

slide-44
SLIDE 44

compound ( compound (n.reindeer n.reindeer) ) gather ( gather (n.reindeer n.reindeer) ) santa santa’ ’s s grotto grotto compound ( compound (n.elves n.elves) ) gather ( gather (g.elves g.elves) ) r.knock r.knock e.knock e.knock report report report report report report report report report report

r r e e i i n n d d e e e e r r e e l l v v e e s s

slide-45
SLIDE 45

santa santa’ ’s s grotto grotto report report santa santa

... ...

g.station g.station g.station g.station g.station g.station

... ...

g.station g.station g.station g.station g.station g.station

slide-46
SLIDE 46

report report initialise initialise

santa.a santa.a santa.b santa.b report report

g.station g.station

santa.a santa.a santa.b santa.b in in

  • ut
  • ut

PROC grotto.station (SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!) WHILE TRUE MOBILE AGENT agent: SEQ CLAIM in ? agent CHAN AGENT.INITIALISE dummy.init: agent (dummy.init?, report!, santa.a!, santa.b!) CLAIM out ! agent : PROC PROC grotto.station grotto.station (SHARED CHAN MOBILE AGENT in?, out!, (SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b!) !) WHILE TRUE WHILE TRUE MOBILE AGENT MOBILE AGENT agent agent: : SEQ SEQ CLAIM in ? agent CLAIM in ? agent CHAN AGENT.INITIALISE CHAN AGENT.INITIALISE dummy.init dummy.init: : agent ( agent (dummy.init dummy.init?, report!, ?, report!, santa.a santa.a!, !, santa.b santa.b!) !) CLAIM out ! agent CLAIM out ! agent : :

slide-47
SLIDE 47

PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!): PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, PROC TYPE AGENT IS (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b! !): ): MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!) IMPLEMENTS AGENT ... : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b! !) ) IMPLEMENTS AGENT IMPLEMENTS AGENT ... ... : :

report report initialise initialise

santa.a santa.a santa.b santa.b

slide-48
SLIDE 48

santa santa’ ’s s grotto grotto report report santa santa

... ...

g.station g.station g.station g.station g.station g.station

... ...

g.station g.station g.station g.station g.station g.station

slide-49
SLIDE 49

PROC santa (CHAN INT elf.a?, elf.b?, CHAN INT reindeer.a?, reindeer.b?, CHAN BOOL elf.knock?, reindeer.knock?, SHARED CHAN SANTA.MESSAGE report) WHILE TRUE BOOL any: PRI ALT reindeer.knock ? any SEQ CLAIM report ! agent.ready; REINDEER.KIND ... engage with reindeer elf.knock ? any SEQ CLAIM report ! agent.ready; ELF.KIND ... engage with elves : PROC PROC santa santa (CHAN INT (CHAN INT elf.a elf.a?, ?, elf.b elf.b?, ?, CHAN INT CHAN INT reindeer.a reindeer.a?, ?, reindeer.b reindeer.b?, ?, CHAN BOOL CHAN BOOL elf.knock elf.knock?, ?, reindeer.knock reindeer.knock?, ?, SHARED CHAN SANTA.MESSAGE report) SHARED CHAN SANTA.MESSAGE report) WHILE TRUE WHILE TRUE BOOL any: BOOL any: PRI ALT PRI ALT reindeer.knock reindeer.knock ? any ? any SEQ SEQ CLAIM report ! CLAIM report ! agent.ready agent.ready; REINDEER.KIND ; REINDEER.KIND ... engage with reindeer ... engage with reindeer elf.knock elf.knock ? any ? any SEQ SEQ CLAIM report ! CLAIM report ! agent.ready agent.ready; ELF.KIND ; ELF.KIND ... engage with elves ... engage with elves : :

report report

santa santa

e.knock e.knock r.knock r.knock r.a r.a r.b r.b e.a e.a e.b e.b

slide-50
SLIDE 50

PROC engage (VAL INT group.size, kind, CHAN INT agent.a?, agent.b?, CHAN BOOL knock?, SHARED CHAN SANTA.MESSAGE report!) INT id: BOOL any: SEQ SEQ i = 0 FOR group.size SEQ agent.a ? id CLAIM report ! greet; kind; id knock ? any -- slam the door SEQ i = 0 FOR group.size agent.b ? id CLAIM report ! engaged; kind ... pause for a (random) while CLAIM report ! disengaged; kind SEQ i = 0 FOR group.size agent.a ? id SEQ i = 0 FOR group.size agent.b ?? id CLAIM report ! goodbye; kind, id : PROC engage (VAL INT PROC engage (VAL INT group.size group.size, kind, , kind, CHAN INT CHAN INT agent.a agent.a?, ?, agent.b agent.b?, ?, CHAN BOOL knock?, CHAN BOOL knock?, SHARED CHAN SANTA.MESSAGE report!) SHARED CHAN SANTA.MESSAGE report!) INT id: INT id: BOOL any: BOOL any: SEQ SEQ SEQ SEQ i = 0 FOR i = 0 FOR group.size group.size SEQ SEQ agent.a agent.a ? id ? id CLAIM report ! greet; kind; id CLAIM report ! greet; kind; id knock ? any knock ? any --

  • - slam the door

slam the door SEQ i = 0 FOR SEQ i = 0 FOR group.size group.size agent.b agent.b ? id ? id CLAIM report ! engaged; kind CLAIM report ! engaged; kind ... pause for a (random) while ... pause for a (random) while CLAIM report ! disengaged; kind CLAIM report ! disengaged; kind SEQ i = 0 FOR SEQ i = 0 FOR group.size group.size agent.a agent.a ? id ? id SEQ i = 0 FOR SEQ i = 0 FOR group.size group.size agent.b agent.b ?? id ?? id CLAIM report ! goodbye; kind, id CLAIM report ! goodbye; kind, id : :

slide-51
SLIDE 51

santa santa’ ’s s grotto grotto report report santa santa

... ...

g.station g.station g.station g.station g.station g.station

... ...

g.station g.station g.station g.station g.station g.station

slide-52
SLIDE 52

report report initialise initialise

santa.a santa.a santa.b santa.b

PROC grotto.station (SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!) WHILE TRUE MOBILE AGENT agent: SEQ CLAIM in ? agent CHAN AGENT.INITIALISE dummy.init: agent (dummy.init?, report!, santa.a!, santa.b!) CLAIM out ! agent : PROC PROC grotto.station grotto.station (SHARED CHAN MOBILE AGENT in?, out!, (SHARED CHAN MOBILE AGENT in?, out!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b!) !) WHILE TRUE WHILE TRUE MOBILE AGENT MOBILE AGENT agent agent: : SEQ SEQ CLAIM in ? agent CLAIM in ? agent CHAN AGENT.INITIALISE CHAN AGENT.INITIALISE dummy.init dummy.init: : agent ( agent (dummy.init dummy.init?, report!, ?, report!, santa.a santa.a!, !, santa.b santa.b!) !) CLAIM out ! agent CLAIM out ! agent : :

report report

g.station g.station

santa.a santa.a santa.b santa.b in in

  • ut
  • ut
slide-53
SLIDE 53

report report

g.station g.station

santa.a santa.a santa.b santa.b in in

  • ut
  • ut

report report initialise initialise

santa.a santa.a santa.b santa.b

MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!) IMPLEMENTS AGENT ... local state declarations SEQ ... in station compound (initialise local state) WHILE TRUE SEQ ... in station compound SUSPEND -- move to gathering place ... in the gathering place SUSPEND -- move to santa’s grotto ... in santa’s grotto SUSPEND -- move to compound : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b! !) ) IMPLEMENTS AGENT IMPLEMENTS AGENT ... local state declarations ... local state declarations SEQ SEQ ... in station compound (initialise local state) ... in station compound (initialise local state) WHILE TRUE WHILE TRUE SEQ SEQ ... in station compound ... in station compound SUSPEND SUSPEND --

  • - move to gathering place

move to gathering place ... in the gathering place ... in the gathering place SUSPEND SUSPEND --

  • - move to

move to santa santa’ ’s s grotto grotto ... in ... in santa santa’ ’s s grotto grotto SUSPEND SUSPEND --

  • - move to compound

move to compound : :

slide-54
SLIDE 54

report report

g.station g.station

santa.a santa.a santa.b santa.b in in

  • ut
  • ut

report report initialise initialise

santa.a santa.a santa.b santa.b

{{{ in santa’s grotto CLAIM santa.a ! id -- say hello to santa CLAIM santa.b ! id -- sync with other agents

  • - and santa

CLAIM report ! busy; kind; id CLAIM santa.a ! id -- wait for santa to finish

  • - working with me

CLAIM report ! done; kind; id CLAIM santa.b ! id -- say goodbye to santa }}} {{{ in {{{ in santa santa’ ’s s grotto grotto CLAIM CLAIM santa.a santa.a ! id ! id --

  • - say hello to

say hello to santa santa CLAIM CLAIM santa.b santa.b ! id ! id --

  • - sync with other agents

sync with other agents

  • - and

and santa santa CLAIM report ! busy; kind; id CLAIM report ! busy; kind; id CLAIM CLAIM santa.a santa.a ! id ! id --

  • - wait for

wait for santa santa to finish to finish

  • - working with me

working with me CLAIM report ! done; kind; id CLAIM report ! done; kind; id CLAIM CLAIM santa.b santa.b ! id ! id --

  • - say goodbye to

say goodbye to santa santa }}} }}}

slide-55
SLIDE 55

compound ( compound (n.reindeer n.reindeer) ) gather ( gather (n.reindeer n.reindeer) ) santa santa’ ’s s grotto grotto compound ( compound (n.elves n.elves) ) gather ( gather (g.elves g.elves) ) r.knock r.knock e.knock e.knock report report report report report report report report report report

r r e e i i n n d d e e e e r r e e l l v v e e s s

Design Summary Design Summary Design Summary

slide-56
SLIDE 56

compound (n) compound (n) report report station station station station station station

... ...

Design Summary Design Summary Design Summary

slide-57
SLIDE 57

compound ( compound (n.reindeer n.reindeer) ) gather ( gather (n.reindeer n.reindeer) ) santa santa’ ’s s grotto grotto compound ( compound (n.elves n.elves) ) gather ( gather (g.elves g.elves) ) r.knock r.knock e.knock e.knock report report report report report report report report report report

r r e e i i n n d d e e e e r r e e l l v v e e s s

Design Summary Design Summary Design Summary

slide-58
SLIDE 58

santa santa’ ’s s grotto grotto report report santa santa

... ...

g.station g.station g.station g.station g.station g.station

... ...

g.station g.station g.station g.station g.station g.station

Design Summary Design Summary Design Summary

slide-59
SLIDE 59

MOBILE PROC reindelf (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT santa.a!, santa.b!) IMPLEMENTS AGENT ... local state declarations SEQ ... in station compound (initialise local state) WHILE TRUE SEQ ... in station compound SUSPEND -- move to gathering place ... in the gathering place SUSPEND -- move to santa’s grotto ... in santa’s grotto SUSPEND -- move to compound : MOBILE PROC MOBILE PROC reindelf reindelf (CHAN AGENT.INITIALISE initialise?, (CHAN AGENT.INITIALISE initialise?, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN AGENT.MESSAGE report!, SHARED CHAN INT SHARED CHAN INT santa.a santa.a!, !, santa.b santa.b! !) ) IMPLEMENTS AGENT IMPLEMENTS AGENT ... local state declarations ... local state declarations SEQ SEQ ... in station compound (initialise local state) ... in station compound (initialise local state) WHILE TRUE WHILE TRUE SEQ SEQ ... in station compound ... in station compound SUSPEND SUSPEND --

  • - move to gathering place

move to gathering place ... in the gathering place ... in the gathering place SUSPEND SUSPEND --

  • - move to

move to santa santa’ ’s s grotto grotto ... in ... in santa santa’ ’s s grotto grotto SUSPEND SUSPEND --

  • - move to compound

move to compound : :

report report initialise initialise

santa.a santa.a santa.b santa.b

Design Summary Design Summary Design Summary

e i t h e r a r e i n d e e r

  • r

a n e l f e i t h e r a r e i n d e e r e i t h e r a r e i n d e e r

  • r

a n e l f

  • r

a n e l f

slide-60
SLIDE 60

Any Questions? Any Questions? Any Questions?