Direct Communication
Processes must name each other explicitly:
- send (P, message) – send a message to process P
- receive(Q, message) – receive a message from process Q
Properties of communication link
- Links are established automatically
- A link is associated with exactly one pair of communicating
processes. - Between each pair there exists exactly one link.
- The link may be unidirectional, but is usually bi-directional.
Asymmetric variant - receive(id, message) – receive a message from any
process, pid stored in id
Indirect Communication
Operations
- create a new mailbox
- send and receive messages through mailbox
destroy a mailbox
Primitives are defined as:
- send(A, message) – send a message to mailbox A
- receive(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.
Buffering
- Queue of messages attached to the link; implemented in
one of three ways.
1. Zero capacity – 0 messages
Sender must wait for receiver (rendezvous).
2. Bounded capacity – finite length of n messages
Sender must wait if link full.
3. Unbounded capacity – infinite length
Sender never waits.
Producer - Consumer Example
- Producer generates an integer between 0 and 9 (inclusive), then stores it in a CubbyHole object. To make the synchronization problem more interesting, the Producer sleeps for a random amount of time between 0 and 100 milliseconds before repeating the number-generating cycle.
- Producer generates an integer between 0 and 9 (inclusive), then stores it in a CubbyHole object. To make the synchronization problem more interesting, the Producer sleeps for a random amount of time between 0 and 100 milliseconds before repeating the number-generating cycle.

No comments:
Post a Comment