22.04.2014 Views

viewing

viewing

viewing

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Recap Probe-Echo algorithms Syncronous communication<br />

Concurrent Programming<br />

Asyncronous and synchronous message passing<br />

1 Recap<br />

2 Probe-Echo algorithms<br />

broadcast<br />

calculating the topology<br />

3 Syncronous communication<br />

November 29<br />

www.hh.se/staff/vero/concurrent


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed Programming<br />

Processes execute without sharing memory, they collaborate by<br />

communicating with each other. Processes exchange messages<br />

with each other.<br />

Asynchronous Message Passing<br />

Communication channels can be used by means of<br />

send, non blocking.<br />

receive, blocking.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed Programming<br />

Processes execute without sharing memory, they collaborate by<br />

communicating with each other. Processes exchange messages<br />

with each other.<br />

Asynchronous Message Passing<br />

Communication channels can be used by means of<br />

send, non blocking.<br />

receive, blocking.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed Programming<br />

Processes execute without sharing memory, they collaborate by<br />

communicating with each other. Processes exchange messages<br />

with each other.<br />

Asynchronous Message Passing<br />

Communication channels can be used by means of<br />

send, non blocking.<br />

receive, blocking.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed Programming<br />

Processes execute without sharing memory, they collaborate by<br />

communicating with each other. Processes exchange messages<br />

with each other.<br />

Asynchronous Message Passing<br />

Communication channels can be used by means of<br />

send, non blocking.<br />

receive, blocking.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed programming<br />

Example<br />

In MPD,<br />

1 We distribute a program by placing resources in different<br />

virtual machines.<br />

2 Each resource might execute one or more processes (which<br />

share the local variables of the resource!)<br />

3 A resource that wants to communicate with some other<br />

resource must export some channel for that purpose.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed programming<br />

Example<br />

In MPD,<br />

1 We distribute a program by placing resources in different<br />

virtual machines.<br />

2 Each resource might execute one or more processes (which<br />

share the local variables of the resource!)<br />

3 A resource that wants to communicate with some other<br />

resource must export some channel for that purpose.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed programming<br />

Example<br />

In MPD,<br />

1 We distribute a program by placing resources in different<br />

virtual machines.<br />

2 Each resource might execute one or more processes (which<br />

share the local variables of the resource!)<br />

3 A resource that wants to communicate with some other<br />

resource must export some channel for that purpose.


Recap Probe-Echo algorithms Syncronous communication<br />

Distributed programming<br />

Example<br />

In MPD,<br />

1 We distribute a program by placing resources in different<br />

virtual machines.<br />

2 Each resource might execute one or more processes (which<br />

share the local variables of the resource!)<br />

3 A resource that wants to communicate with some other<br />

resource must export some channel for that purpose.


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

resource Sensor<br />

op deploy([*]cap Sensor nbgs)<br />

op chan(int id, double value)<br />

body Sensor(int identity, int interval, int netSize)<br />

[netSize] cap Sensor neighbours<br />

int nrOfNeighbours<br />

procedure measure(){...}<br />

procedure communicate(){...}<br />

procedure work(){co measure() // communicate() oc}<br />

proc deploy(nbgs){<br />

nrOfNeighbours = ub(nbgs)-lb(nbgs) + 1<br />

for[i = 1 to nrOfNeighbours]{neighbours[i]=nbgs[i]}<br />

work()<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

Example<br />

1 A program will create some sensors by letting each sensor run<br />

in its own virtual machine:<br />

cap Sensor s = create Sensor(id, interval, size)<br />

on machine<br />

2 and deploy the network by providing each sensor with its<br />

neighbours<br />

s.deploy(ns)<br />

(where ns is an array of sensors.)<br />

3 We then have a distributed program, where the sensors do<br />

some local work while they can also collaborate with each<br />

other to do some work together.


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

Example<br />

1 A program will create some sensors by letting each sensor run<br />

in its own virtual machine:<br />

cap Sensor s = create Sensor(id, interval, size)<br />

on machine<br />

2 and deploy the network by providing each sensor with its<br />

neighbours<br />

s.deploy(ns)<br />

(where ns is an array of sensors.)<br />

3 We then have a distributed program, where the sensors do<br />

some local work while they can also collaborate with each<br />

other to do some work together.


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

Example<br />

1 A program will create some sensors by letting each sensor run<br />

in its own virtual machine:<br />

cap Sensor s = create Sensor(id, interval, size)<br />

on machine<br />

2 and deploy the network by providing each sensor with its<br />

neighbours<br />

s.deploy(ns)<br />

(where ns is an array of sensors.)<br />

3 We then have a distributed program, where the sensors do<br />

some local work while they can also collaborate with each<br />

other to do some work together.


Recap Probe-Echo algorithms Syncronous communication<br />

MPD sensor network<br />

Example<br />

1 A program will create some sensors by letting each sensor run<br />

in its own virtual machine:<br />

cap Sensor s = create Sensor(id, interval, size)<br />

on machine<br />

2 and deploy the network by providing each sensor with its<br />

neighbours<br />

s.deploy(ns)<br />

(where ns is an array of sensors.)<br />

3 We then have a distributed program, where the sensors do<br />

some local work while they can also collaborate with each<br />

other to do some work together.


Recap Probe-Echo algorithms Syncronous communication<br />

Plan<br />

Today<br />

Process interaction in distributed programs:<br />

Probe-Echo algorithms using asynchronous message passing<br />

(MPD)<br />

Synchronous communication, reactive objects (MPD)<br />

Next lectures<br />

More constructions for communication: Remote Procedure<br />

Call (remote method invocation in Java).<br />

One new paradigm of interaction: client-server.


Recap Probe-Echo algorithms Syncronous communication<br />

Plan<br />

Today<br />

Process interaction in distributed programs:<br />

Probe-Echo algorithms using asynchronous message passing<br />

(MPD)<br />

Synchronous communication, reactive objects (MPD)<br />

Next lectures<br />

More constructions for communication: Remote Procedure<br />

Call (remote method invocation in Java).<br />

One new paradigm of interaction: client-server.


Recap Probe-Echo algorithms Syncronous communication<br />

Probe-Echo algorithms<br />

We assume processes are executing in distributed nodes (mpd<br />

resources).<br />

That some nodes can communicate with some other nodes can be<br />

modelled using graphs.<br />

Nodes are resources that can<br />

communicate with their<br />

neighbours in the graph.<br />

Nodes send probes to their<br />

neighbours and receive echos<br />

from them.


Recap Probe-Echo algorithms Syncronous communication<br />

Probe-Echo algorithms<br />

We assume processes are executing in distributed nodes (mpd<br />

resources).<br />

That some nodes can communicate with some other nodes can be<br />

modelled using graphs.<br />

Nodes are resources that can<br />

communicate with their<br />

neighbours in the graph.<br />

Nodes send probes to their<br />

neighbours and receive echos<br />

from them.


Recap Probe-Echo algorithms Syncronous communication<br />

Probe-Echo algorithms<br />

We assume processes are executing in distributed nodes (mpd<br />

resources).<br />

That some nodes can communicate with some other nodes can be<br />

modelled using graphs.<br />

Nodes are resources that can<br />

communicate with their<br />

neighbours in the graph.<br />

Nodes send probes to their<br />

neighbours and receive echos<br />

from them.


Recap Probe-Echo algorithms Syncronous communication<br />

Probe-Echo algorithms<br />

We assume processes are executing in distributed nodes (mpd<br />

resources).<br />

That some nodes can communicate with some other nodes can be<br />

modelled using graphs.<br />

Nodes are resources that can<br />

communicate with their<br />

neighbours in the graph.<br />

Nodes send probes to their<br />

neighbours and receive echos<br />

from them.


Recap Probe-Echo algorithms Syncronous communication<br />

Probe-Echo algorithms<br />

We assume processes are executing in distributed nodes (mpd<br />

resources).<br />

That some nodes can communicate with some other nodes can be<br />

modelled using graphs.<br />

Nodes are resources that can<br />

communicate with their<br />

neighbours in the graph.<br />

Nodes send probes to their<br />

neighbours and receive echos<br />

from them.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcast in a network<br />

Probes can be used for a process to broadcast a message to all<br />

other nodes in a network.<br />

1 Each resource will have a channel to do<br />

broadcast<br />

2 Each resource will have a process engaged in<br />

broadcast<br />

3 This process will<br />

1 wait to receive the message<br />

2 send it to all its neighbours<br />

4 Some other process in one resource starts<br />

the broadcast.


Recap Probe-Echo algorithms Syncronous communication<br />

Doesn’t work!<br />

What will happen in the next broadcast?<br />

Because a node might be a<br />

neighbour to more than one node,<br />

there might be many messages<br />

sent to its broadcast channel!<br />

They will be read in the next<br />

receive, instead for the new<br />

message being broadcast!<br />

Empty the channel by receiving from all other neighbours (and<br />

throwing the messages away!)


Recap Probe-Echo algorithms Syncronous communication<br />

Doesn’t work!<br />

What will happen in the next broadcast?<br />

Because a node might be a<br />

neighbour to more than one node,<br />

there might be many messages<br />

sent to its broadcast channel!<br />

They will be read in the next<br />

receive, instead for the new<br />

message being broadcast!<br />

Empty the channel by receiving from all other neighbours (and<br />

throwing the messages away!)


Recap Probe-Echo algorithms Syncronous communication<br />

Doesn’t work!<br />

What will happen in the next broadcast?<br />

Because a node might be a<br />

neighbour to more than one node,<br />

there might be many messages<br />

sent to its broadcast channel!<br />

They will be read in the next<br />

receive, instead for the new<br />

message being broadcast!<br />

Empty the channel by receiving from all other neighbours (and<br />

throwing the messages away!)


Recap Probe-Echo algorithms Syncronous communication<br />

Doesn’t work!<br />

What will happen in the next broadcast?<br />

Because a node might be a<br />

neighbour to more than one node,<br />

there might be many messages<br />

sent to its broadcast channel!<br />

They will be read in the next<br />

receive, instead for the new<br />

message being broadcast!<br />

Empty the channel by receiving from all other neighbours (and<br />

throwing the messages away!)


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

Works!<br />

The algorithm<br />

In each resource the process engaged in broadcast will<br />

1 Receive the message in a dedicated channel<br />

2 Send the message to all its neighbours<br />

3 Receive in the dedicated channel as many times as number of<br />

neighbours -1.<br />

How does everything start?<br />

In some resource, an initiator process will send the original message<br />

to the broadcast process in that resource!<br />

What happens with the boadcast process in the resource of the<br />

initiator? What can be done about it?


Recap Probe-Echo algorithms Syncronous communication<br />

A better broadcast<br />

In the previous algorithm there were many messages that were sent<br />

and then just discarded! Could a process guide the message?<br />

. . . it can construct a spanning<br />

tree . . .<br />

If the initiator node S knows all of<br />

the graph . . .<br />

. . . where each node can find its<br />

relevant neighbours for the<br />

broadcast!<br />

The spanning tree has to be sent<br />

as part of the message!


Recap Probe-Echo algorithms Syncronous communication<br />

A better broadcast<br />

In the previous algorithm there were many messages that were sent<br />

and then just discarded! Could a process guide the message?<br />

If the initiator node S knows all of<br />

the graph . . .<br />

. . . it can construct a spanning<br />

tree . . .<br />

. . . where each node can find its<br />

relevant neighbours for the<br />

broadcast!<br />

The spanning tree has to be sent<br />

as part of the message!


Recap Probe-Echo algorithms Syncronous communication<br />

A better broadcast<br />

In the previous algorithm there were many messages that were sent<br />

and then just discarded! Could a process guide the message?<br />

If the initiator node S knows all of<br />

the graph . . .<br />

. . . it can construct a spanning<br />

tree . . .<br />

. . . where each node can find its<br />

relevant neighbours for the<br />

broadcast!<br />

The spanning tree has to be sent<br />

as part of the message!


Recap Probe-Echo algorithms Syncronous communication<br />

A better broadcast<br />

In the previous algorithm there were many messages that were sent<br />

and then just discarded! Could a process guide the message?<br />

If the initiator node S knows all of<br />

the graph . . .<br />

. . . it can construct a spanning<br />

tree . . .<br />

. . . where each node can find its<br />

relevant neighbours for the<br />

broadcast!<br />

The spanning tree has to be sent<br />

as part of the message!


Recap Probe-Echo algorithms Syncronous communication<br />

A better broadcast<br />

In the previous algorithm there were many messages that were sent<br />

and then just discarded! Could a process guide the message?<br />

If the initiator node S knows all of<br />

the graph . . .<br />

. . . it can construct a spanning<br />

tree . . .<br />

. . . where each node can find its<br />

relevant neighbours for the<br />

broadcast!<br />

The spanning tree has to be sent<br />

as part of the message!


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Gathering the topology<br />

Two steps<br />

1 Send a probe to all neighbours.<br />

2 Send back an echo with the partial topology to the process<br />

that sent the first probe.<br />

What is a graph?<br />

In this context we will model graphs using an adjacency matrix<br />

The spanning tree is also a graph!<br />

1 2 3 4 5 6 7<br />

1 f t f f f f t<br />

2 t f t f f t f<br />

3 f t f t t t f<br />

4 f f t f t f f<br />

5 f f t t f f t<br />

6 f t t f f f t<br />

7 t f f f t t f


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

All resources involved in calculating the topology will use the<br />

following types:<br />

type graph = bool [n,n]<br />

type kind = enum (PROBE, ECHO)<br />

The resources export a channel<br />

op probe_echo(kind k, int sender, graph topology)<br />

The resource collecting the topology uses one extra channel<br />

op finalecho(graph topology)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

The resource s that will collect the topology starts everyting doing<br />

graph topology<br />

send probe_echo(PROBE,s,allFalse)<br />

receive finalecho(topology)<br />

All resources in the network will have a process involved in<br />

collecting the topology. For this it will use<br />

graph newtop, localtop # all false!<br />

Recall that each resource knows what resources are its neighbours<br />

bool links[n]


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Calculating the topology<br />

The algorithm<br />

1 Initialize localtop with links .<br />

2 Receive the probe from one neighbour (the first one!)<br />

3 Send the probe to all other neighbours!<br />

4 Receive redundant probes and echoes:<br />

If it is an echo, build the local topology by adding the received<br />

topology (Just a logical or between the matrices!)<br />

If it is a probe, send the empty topology as echo back to the<br />

sender.<br />

5 Send an echo back to the first sender (or to the finalecho if<br />

the process is executing in the resource s)


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

So, now we know that one resource (a node in the graph) can<br />

calculate the topology of the network by collaborating with other<br />

resources using a probe/echo pattern of communication.<br />

It is easy for that node to calculate a spanning tree<br />

Spanning tree<br />

A sub-graph with only one path from the root to any other node<br />

using some of the edges in the original graph.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

So, now we know that one resource (a node in the graph) can<br />

calculate the topology of the network by collaborating with other<br />

resources using a probe/echo pattern of communication.<br />

It is easy for that node to calculate a spanning tree<br />

Spanning tree<br />

A sub-graph with only one path from the root to any other node<br />

using some of the edges in the original graph.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

So, now we know that one resource (a node in the graph) can<br />

calculate the topology of the network by collaborating with other<br />

resources using a probe/echo pattern of communication.<br />

It is easy for that node to calculate a spanning tree<br />

Spanning tree<br />

A sub-graph with only one path from the root to any other node<br />

using some of the edges in the original graph.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

So, now we know that one resource (a node in the graph) can<br />

calculate the topology of the network by collaborating with other<br />

resources using a probe/echo pattern of communication.<br />

It is easy for that node to calculate a spanning tree<br />

Spanning tree<br />

A sub-graph with only one path from the root to any other node<br />

using some of the edges in the original graph.


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

So, now we know that one resource (a node in the graph) can<br />

calculate the topology of the network by collaborating with other<br />

resources using a probe/echo pattern of communication.<br />

It is easy for that node to calculate a spanning tree<br />

Spanning tree<br />

A sub-graph with only one path from the root to any other node<br />

using some of the edges in the original graph.


Recap Probe-Echo algorithms Syncronous communication<br />

calculating a spanning tree


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

The algorithm<br />

Let the channel that all resources export deal with both messages<br />

and a spanning tree:<br />

op probe(double value, graph sptree)<br />

Then the process in each resource involved in the broadcast will<br />

just<br />

1 Receive the message and the spanning tree (from only one<br />

process!)<br />

2 Send the message and the spanning tree only to the<br />

neighbours in the spanning tree!


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

The algorithm<br />

Let the channel that all resources export deal with both messages<br />

and a spanning tree:<br />

op probe(double value, graph sptree)<br />

Then the process in each resource involved in the broadcast will<br />

just<br />

1 Receive the message and the spanning tree (from only one<br />

process!)<br />

2 Send the message and the spanning tree only to the<br />

neighbours in the spanning tree!


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

The algorithm<br />

Let the channel that all resources export deal with both messages<br />

and a spanning tree:<br />

op probe(double value, graph sptree)<br />

Then the process in each resource involved in the broadcast will<br />

just<br />

1 Receive the message and the spanning tree (from only one<br />

process!)<br />

2 Send the message and the spanning tree only to the<br />

neighbours in the spanning tree!


Recap Probe-Echo algorithms Syncronous communication<br />

Broadcasting revisited<br />

The algorithm<br />

Let the channel that all resources export deal with both messages<br />

and a spanning tree:<br />

op probe(double value, graph sptree)<br />

Then the process in each resource involved in the broadcast will<br />

just<br />

1 Receive the message and the spanning tree (from only one<br />

process!)<br />

2 Send the message and the spanning tree only to the<br />

neighbours in the spanning tree!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvouz<br />

It is very difficult to synchronize processes using asyncronous<br />

message passing! We would like to attack problems like waiting on<br />

conditions in the setting of distributed programming.<br />

Think of the primitive of sending a message to another process<br />

leaving the sender process suspended until the message is received<br />

and processed! At that point the processes can handshake or<br />

rendezvous.<br />

The receiving operation will have a queue of waiting processes,<br />

instead of a queue of messages!<br />

Implementations of these primitives in programming languages can<br />

include<br />

Returning a value to the calling process!<br />

Add conditions to the receive primitive for blocking senders!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The channel is declared as an op with fields for the message and<br />

possibly a return type:<br />

resource TimeServer<br />

op getTime() returns int<br />

op delay(int)


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The operation is serviced by an in statement:<br />

in getTime() returns time -> time = tod ni<br />

in a process that is executing concurrently with the sender!<br />

Between in and ->: the<br />

guard<br />

Between in and ni: a<br />

guarded operation<br />

The process executing the in<br />

is delayed until there is at<br />

least one pending call on the<br />

channel getTime<br />

Then it selects the oldest<br />

pending call and executes the<br />

operation time = tod<br />

At this point both processes<br />

can proceed!


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The general form of in<br />

A process servicing an in can serve several alternatives:<br />

in getTime() returns time<br />

-> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

and a guard can include a boolean expression!<br />

The process executing the in will<br />

Delay until some guard succeeds (there is a call to the channel<br />

and the boolean expression is true).<br />

The oldest invocation is served by executing its action.<br />

After, both the caller and the service can continue.


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The general form of in<br />

A process servicing an in can serve several alternatives:<br />

in getTime() returns time<br />

-> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

and a guard can include a boolean expression!<br />

The process executing the in will<br />

Delay until some guard succeeds (there is a call to the channel<br />

and the boolean expression is true).<br />

The oldest invocation is served by executing its action.<br />

After, both the caller and the service can continue.


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The general form of in<br />

A process servicing an in can serve several alternatives:<br />

in getTime() returns time<br />

-> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

and a guard can include a boolean expression!<br />

The process executing the in will<br />

Delay until some guard succeeds (there is a call to the channel<br />

and the boolean expression is true).<br />

The oldest invocation is served by executing its action.<br />

After, both the caller and the service can continue.


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The general form of in<br />

A process servicing an in can serve several alternatives:<br />

in getTime() returns time<br />

-> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

and a guard can include a boolean expression!<br />

The process executing the in will<br />

Delay until some guard succeeds (there is a call to the channel<br />

and the boolean expression is true).<br />

The oldest invocation is served by executing its action.<br />

After, both the caller and the service can continue.


Recap Probe-Echo algorithms Syncronous communication<br />

Rendezvous in MPD<br />

The general form of in<br />

A process servicing an in can serve several alternatives:<br />

in getTime() returns time<br />

-> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

and a guard can include a boolean expression!<br />

The process executing the in will<br />

Delay until some guard succeeds (there is a call to the channel<br />

and the boolean expression is true).<br />

The oldest invocation is served by executing its action.<br />

After, both the caller and the service can continue.


Recap Probe-Echo algorithms Syncronous communication<br />

A time server<br />

A process that can be used by<br />

other processes to be delayed until<br />

some deadline. Processes can use<br />

the time server to set up alarms!


Recap Probe-Echo algorithms Syncronous communication<br />

The time server<br />

resource TimeServer<br />

op getTime() returns int<br />

op delay(int)<br />

body TimeServer()<br />

process timer{<br />

int tod = 0 # time of day<br />

while(true){<br />

in getTime() returns time -> time = tod<br />

[] delay(waketime) and waketime skip<br />

ni<br />

}<br />

}<br />

end


Recap Probe-Echo algorithms Syncronous communication<br />

Using the time server<br />

Example<br />

resource Test<br />

import TimeServer<br />

body Test()<br />

cap TimeServer ts = create TimeServer()<br />

process A{<br />

int i = 0;<br />

while(true){<br />

call ts.delay(20*i++);<br />

write(ts.getTime()/20);<br />

}<br />

}<br />

Notice the use of call! When we use the results we can omit the<br />

call (as inside the write).


Recap Probe-Echo algorithms Syncronous communication<br />

Using the time server<br />

Example<br />

resource Test<br />

import TimeServer<br />

body Test()<br />

cap TimeServer ts = create TimeServer()<br />

process A{<br />

int i = 0;<br />

while(true){<br />

call ts.delay(20*i++);<br />

write(ts.getTime()/20);<br />

}<br />

}<br />

Notice the use of call! When we use the results we can omit the<br />

call (as inside the write).


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

Asynchronous message passing revisited<br />

Example<br />

How did the TimeServer keep track of the time? (increment tod)<br />

There will be a hardware<br />

process associated to the<br />

computer clock that<br />

asynchronously and<br />

periodically sends messages<br />

to the TimeServer!<br />

On receiving such messages<br />

tod will be incremented.<br />

In MPD a receive is just an<br />

abbreviation for an operation<br />

serviced by an in and invoked<br />

with a send!<br />

Serviced by in invoked by<br />

call: Rendezvous!<br />

Serviced by in invoked by<br />

send: Asynchronous<br />

message passing!


Recap Probe-Echo algorithms Syncronous communication<br />

The time server revisited<br />

resource TimeServer<br />

op getTime() returns int<br />

op delay(int)<br />

op tick()<br />

body TimeServer()<br />

process timer{<br />

int tod = 0 # time of day<br />

while(true){<br />

in getTime() returns time -> time = tod<br />

[] delay(waketime) and waketime skip<br />

[] tick() -> tod++<br />

ni<br />

}<br />

}<br />

end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!