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.
– The link may be unidirectional (e.g. signaling), but is
usually bi-directional (e.g. sockets).
----------
INDIRECT COMMUNICATION
• Messages are directed and received from
mailboxes (also referred to as ports).
– Each mailbox has a unique id. (e.g. shared memory,
shared file, message Q)
– Processes can communicate only if they share a
mailbox.
• Properties of communication link
– A link may be associated with many processes.
– Each pair of processes may share several
communication links.
– Link may be unidirectional or bi-directional.
• 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
• Blocking send
- suspend sending process until message received
• Nonblocking send
- resume process immediately after sending message
• Blocking receive
- suspend receiving process until data is received
• Nonblocking receive
- return either a message or
- null if no message is immediately available
Synchronization Trade-Offs
• Blocking
- guarantees message has been delivered
- drastically reduces performance
• Non-Blocking
- much better performance (hides latency of message sending)
- could cause errors if messages are lost
----------
BUFFERING
• Buffering allows messages to be saved and read or transmitted later
• Requires sufficient memory to store messages
• Can drastically improve performance of applications
Types of Buffering
• Zero Capacity
- no buffering at all
- must be "listening" when a message comes in
• Bounded Capacity
- some max, n, of messages will be buffered
- be careful when queue gets full
• Unbounded Capacity
- no limit to the number of message
- not usually very realistic assumption
- this is not very realistic, buffers usually have finite capacity
----------
Producer-Consumer Example
• One process generates data – the producer
• The other process uses it – the consumer
• If directly connected – time coordination
- How would they coordinate the time ??
• One process generates data – the producer
• The other process uses it – the consumer
• If not directly connected – have a buffer
- Buffer must be accessible to both
- Finite Capacity N – Number in use - K
0 comments:
Post a Comment