Asynchronous Message Passing AMP
Prabhaker Mateti
This web page is organized in way that is useful during my lecture,
instead of ppt slides.
Asynchronous Message Passing AMP
- send message e to process B
-- e an expression
- receive message x from process A
-- var x local to B
- receiver waits if there are no messages
- send operation never blocks
-- implies infinite buffering
-- no implied synchronization
-- can send messages to self
-- communication only
- Order of receive = Order of send
- sender and receiver execute independently
- "time gap" between send and the corresponding receive can be large
Channels
- A PL construct for AMP
ex: channel semop[1 .. n](sender: int, k: kind, timestamp: int)
- send semop[j](i, VEE, lc)
-- selects one channel (semop[j]) and deposits the triplet (i, VEE, lc)
-- i, VEE, lc are expressions of types int, kind, int
- receive semop[j](i, v, lc)
-- selects one channel (semop[j]) and retrieves a triplet
-- i, v, lc are local variables of the receiving process of types int, kind, int
-- i, v, lc are assigned the triplet's values
- broadcast semop(i, VEE, lc)
-- does send semop[j](i, VEE, lc) for all j: 1 .. n
-- in parallel
Event Ordering
- An event is the execution of anything: a statement, a send, a
receive, etc.
- Any two events a and b in a single process (i.e., without //, only
has ; and []) are clearly ordered:
either a happens before b (written a → b) or the otherway (b
→ a).
- Let a and b be two events taken from two processes.
Can we order these two?
If a is the sending of a message, and b is the receiving
of that message, we can see that
a → b.
- What if a and b are not so? We cannot say either that a → b
or the otherway b → a.
- Happens Before is transitive:
a → b and b → c implies a → c.
- Events across processes are only partially ordered.
Logical Clocks
- Distributed systems do not have central clocks.
- Yet, we desire to establish a total order among events across
processes. That is, we wish either a → b or b → a even
when a and b are not from the same process or send/receives.
- A logical clock is a private counter maintained by each
process.
- On every event, lc := lc + 1.
- Include lc as part of every message sent, as the time stamp of the sender.
- On receiving(m, ts), receiver does lc := max(lc, ts+1) + 1
- Assume lc never overflows.
Exercises
- Discuss: Asynchronous message passing is more
fundamental than synchronous message passing. That is, given
SMP send/recv can we construct AMP send/recv?
- Discuss: Peer-to-peer distributed computing is just an academic
term for the commercial term client-server computing.
References
- Gregory R. Andrews, Concurrent Programming: Principles and
Practice, Benjamin/Cummings, 1991. Chapter 7 on AMP. Required
Reading.
-
http://en.wikipedia.org/wiki/Happened-before