Lecture-02. Message Passing
Lecture-02. Message Passing
Rajiv Misra
Dept. of Computer Science & Engineering
Indian Institute of Technology Patna
[email protected]
Preface
Recap of previous lecture:
• Distributed Algorithms assume asynchrony, local knowledge and failures.
Content of this lecture:
• This lecture introduces the formal model of a distributed message
passing system. Two main timing models, synchronous and
asynchronous are considered.
• Few simple algorithms for message-passing systems with arbitrary
topology, both synchronous and asynchronous will be discussed.
• These algorithms broadcast information, collect information, and
construct spanning trees of the network.
Message-Passing Model
• In a message-passing system, processors communicate by
sending messages over communication channels, where
each channel provides a bidirectional connection between
two specific processors.
• The pattern of connections provided by the channels
describes the topology of the system.
• The collection of channels is often referred to as the network
Message-Passing Model
• More formally, a system or algorithm consists of n
processors p0, p1, …, pn-1 ; i is the index of processor pi
(nodes of graph)
• bidirectional point-to-point channels
(undirected edges of graph)
• each processor labels its incident channels 1, 2, 3,…; might
not know who is at other end
Message-Passing Model
1 1
p3 p0
2 3
2
2
p2 p1
1 1
Modeling Processors and Channels
• Processor is a state machine including
• local state of the processor
• mechanisms for modeling channels
• Channel directed from processor pi to processor pj is modeled in two
pieces:
• outbuf variable of pi and
• inbuf variable of pj
• Outbuf corresponds to physical channel, inbuf to incoming message
queue
Modeling Processors and Channels
inbuf[1] outbuf[2]
p1's local
variables p2's local
variables
outbuf[1] inbuf[2]
Sender p1 m3 m2 m1 Receiver
p2
Sender p1 m3 m2 m1 p2 Receiver
(ii) Computation Event
c old d e new
local local
state state
• Format is
config, event, config, event, config, …
• in first config: each processor is in initial state and all inbufs are
empty
• for each consecutive (config, event, config), new config is same as
old config except:
• if delivery event: specified msg is transferred from sender's outbuf to
receiver's inbuf
• if computation event: specified processor's state (including outbufs)
change according to transition function
Admissibility
• Synchronous model:
• time is depth d of the spanning tree. ( at most n – 1 when chain)
• number of messages is n - 1, since one message is sent over each
spanning tree edge
• Asynchronous model:
• same as synchronous ie time (d) and messages (n-1)
Convergecast: Concept
b,d c,f,h
b c
g h
solid arrows:
g h
parent-child relationships
Convergecast: Example
• use "parent" and "reject" msgs to set children variables and know when
to terminate (after hearing from all neighbors)
Execution of Spanning Tree Algorithm
root root
a a
Both models:
O(m) messages
b c O(diam) time b c
d e f d e f
g h g h
b c b c
d e f d e f
g h g h
• Previous algorithm ensures that the spanning tree is always a DFS tree.
• Analogous to sequential DFS algorithm.
• Message complexity: O(m) since a constant number of messages are
sent over each edge
• Time complexity: O(m) since each edge is explored in series.
Finding a Spanning Tree Without a Root