CEG 7370: Distributed Computing Principles

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

  1. send message e to process B
    -- e an expression
  2. receive message x from process A
    -- var x local to B
  3. receiver waits if there are no messages
  4. send operation never blocks
    -- implies infinite buffering
    -- no implied synchronization
    -- can send messages to self
    -- communication only
  5. Order of receive = Order of send
  6. sender and receiver execute independently
  7. "time gap" between send and the corresponding receive can be large

Channels

  1. A PL construct for AMP
    ex: channel semop[1 .. n](sender: int, k: kind, timestamp: int)
  2. 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
  3. 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
  4. broadcast semop(i, VEE, lc)
    -- does send semop[j](i, VEE, lc) for all j: 1 .. n
    -- in parallel

Event Ordering

  1. An event is the execution of anything: a statement, a send, a receive, etc.
  2. 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).

  3. 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.

  4. What if a and b are not so? We cannot say either that a → b or the otherway b → a.
  5. Happens Before is transitive:

    a → b and b → c implies a → c.

  6. Events across processes are only partially ordered.

Logical Clocks

  1. Distributed systems do not have central clocks.
  2. 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.
  3. A logical clock is a private counter maintained by each process.
  4. On every event, lc := lc + 1.
  5. Include lc as part of every message sent, as the time stamp of the sender.
  6. On receiving(m, ts), receiver does lc := max(lc, ts+1) + 1
  7. Assume lc never overflows.

Exercises

  1. Discuss: Asynchronous  message passing is more fundamental than synchronous message passing. That is, given SMP send/recv can we construct AMP send/recv?
  2. Discuss: Peer-to-peer distributed computing is just an academic term for the commercial term client-server computing.

References

  1. Gregory R. Andrews, Concurrent Programming: Principles and Practice, Benjamin/Cummings, 1991. Chapter 7 on AMP. Required Reading.
  2. http://en.wikipedia.org/wiki/Happened-before

Copyright © 2012 Prabhaker Mateti