• Mechanism for processes to communicate and to synchronize
their actions.
• Message system – processes communicate with each other
without resorting to shared variables.
• IPC facility provides two operations:
– send(message) – message size fixed or variable
– receive(message)
• If P and Q wish to communicate, they need to:
– establish a communication link between them
– exchange messages via send/receive
• Implementation of communication link
– physical (e.g., shared memory, hardware bus)
– logical (e.g., logical properties)
DIRECT COMMUNICATION
• Processes must name each other explicitly:
– Symmetric Addressing
• Send (P, message) – send to process P
• Receive(Q, message) – receive from Q
– Asymmetric Addressing
•send (P, message) – send to process P
•receive(id, message) – rx from any; system sets id = sender
•Primitives:
–send(A, message) – send a message to mailbox A
–receive(A, message) – receive a message from mailbox A
•Properties of Communication Link
–Links established automatically between pairs
–processes must know each others ID
–Exactly one link per pair of communicating processes
•Disadvantage: a process must know the name or ID of the process(es) it wishes to communicate with
INDIRECT COMMUNICATION
• Messages are directed and received from mailboxes(also referred to as ports).
- Each mailbox has a unique id.
- Processes can communicate only if they share a mailbox.
• Properties of communication link
- Link established only if processes share a common mailbox
- A link may be associated with many processes.
- Each pair of processes may share several communicationlinks.
- 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 to mailbox Areceive(A, message)
– receive a message from mailbox A
• Mailbox sharingF P1, P2, and P3 share mailbox A.
- P1, sends; P2 and P3 receive.
- Who gets the message?
• Solutions
- Allow a link to be associated with at most two processes.
- Allow only one process at a time to execute a receiveoperation.
-Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.
SYNCHRONIZATION
• Message passing may be either blocking or non-blocking.
–Blocking Send: sender blocked until message received by mailbox or process
–Nonblocking Send: sender resumes operation immediately after sending
–Blocking Receive: receiver blocks until a message is available
–Nonblocking Receive: receiver returns immediately with either a valid or null message.
• Blocking is considered synchronous
• Non-blocking is considered asynchronous
• Send and receive primitives may be either blocking or non-blocking.
BUFFERING
• All messaging system require framework to temporarily buffer messages. These queues are 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 lengthSender never waits.
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