Thursday, July 30, 2009

Interprocess Communication

  • Direct Communication


–each process wanting to communicate must explicitly name the recipient or sender of the communication

–send and receive primitives defined:
send ( P, message ) : send a message to process P
receive ( Q, message ) : receive a message from process Q


–a link established automatically between every pair of processes that want to communicate
»processes only need to know each other’s identity

–link is associated with exactly two processes

–link is usually bidirectional but can be unidirectional

– Process A Process Bwhile (TRUE) { while (TRUE) { produce an item receive ( A, item ) send ( B, item ) consume item} }

  • Indirect Communication


•messages sent to and received from mailboxes (or ports)

–mailboxes can be viewed as objects into which messages placed by processes and from which messages can be removed by other processes

–each mailbox has a unique ID

–two processes can communicate only if they have a shared mailbox


send ( A, message ) : send a message to mailbox Areceive ( A, message ) :

receive a message from mailbox A

  • Synchronization

- Message passing may be either blocking or non-blocking.

• Blocking is considered synchronous

• Non-blocking is considered asynchronous

- Send and receive primitives may be either blocking or non-blocking.

No comments: