Lect2 - MESSAGE PASSING
Lect2 - MESSAGE PASSING
Lect2 - MESSAGE PASSING
Shared
P1 Memory P2
Area
P1 P2
Easy to use.
Straight forward to construct new application.
Provide primitives so as to enable to
communicate with existing application.
Uniform Semantics
It consists of a
◦ Fixed-length header
◦ Variable-size collection of typed data objects.
A typical message structure
Other primitives:
◦ Send primitive
◦ Receive primitive
Cont…
Blocking send primitive:
◦ After execution of the send statement, the sending
process is blocked until it receives an
acknowledgement.
Receive (message);
Execution suspended
Send (message); Message
Execution suspended
Execution resumed
Blocked state
executing state
Issues In Non-blocking
2nd strategy
– The message is simply discarded and the time
out mechanism is used to resend message
after a time out period.
Message
34
Cont..
The null buffer strategy is not suitable for
synchronous communication between two
processes in a distributed system.
Sending Receiving
process process
Message
38
Unbounded-capacity buffer
Buffer with unbounded-capacity message may be
used in the asynchronous mode of
communication.
It can store all unreceived messages with the
assurance that all messages sent to the receiver
will be delivered.
This strategy is practically impossible.
Finite Bound Buffer
Asynchronous mode of communication uses
this strategy of finite bound buffer.
40
Cont…
Methods to deal with the problem of buffer
overflow:
◦ Unsuccessful communication
Message transfers simply fail whenever there is no more
buffer space.
◦ Flow-controlled communication
The sender is blocked until the receiver accepts some
messages, thus creating space in the buffer for new
messages.
41
Cont…
A create-buffer system call is provided to the user.
42
Cont…
Sending Receiving
process Message 1 process
Message 2
Message Message 3
Message n
Multiple-message
Buffer/mailbox/port
43
Multidatagram messages
A message whose size is greater than the MTU
(maximum transfer unit) is fragmented into
multiples of the MTU.
45
Cont…
Difficult to achieve because
An absolute pointer losses its meaning when
transferred from one process AS to another.
◦ Requires flattening and shaping of objects.
Receiver process should have a-priori knowledge of
varying memory occupied by various data items.
46
Cont…
Two representation may be used for encoding and
Decoding :
1. Tagged Representation
2. Untagged Representation
47
Cont…
Tagged Representation
Data object along with its type is encoded.
Used in A.S.N (CCITT 1985).
Untagged Representation
No information regarding data type.
Used in SUN XDR (Extended Data Representation).
48
Cont…
The tagged representation is more expensive
than untagged representation in terms of
The quantity of data transferred and
The processing time needed at each side to encode
and decode the message data.
49
Process Addressing
50
Explicit Addressing
The process with which communication is desired
is explicitly named as a parameter in the
communication primitive used.
51
Implicit Addressing
55
Cont…
Benefit:
No global coordination required for local-id
Drawback
◦ It does not allow a process to migrate from one machine
to another on requirement like
One or more processes of a heavily loaded machine may be
migrated to a lightly loaded machine to balance the overall
system load.
Cont…
Solution
◦ Processes can be identified by a combination of the
three fields
machine_id
Local_id
machine_id
Cont…
Machine-id , Local-id , Machine-id ,
Node on which
process created Id of the process Last known Node
Location of the process
58
Cont…
Drawbacks in this:
◦ The overload of locating a process may be large if the
process has migrated several times during its lifetime.
Solutions are:
– Ensure that the system wide unique identifier of a
process does not contain an embedded machine
identifier.
– Use Two-level naming scheme for processes.
Two Level Naming Scheme
61
Cont…
When a process wants to send a message to another
process, it specifies high level name of the receiver
process.
64
Cont…
sender Receiver
Send request
Request message
lost
sender Receiver
lost
sender Receiver
unsuccessful request
crash execution
restarted
Receiver’s PC crashed.
Cont…
To overcome these problems
• A reliable IPC protocol of a message-passing
system is designed.
• It is based on the ideas of internal retransmission
of messages after time out and
• Return of an ACK to sending m/c kernel by
receiver m/c kernel.
68
Cont…
Protocols used for client-server communication
between two processes are:
◦ Four-message reliable IPC protocol
◦ Three -message reliable IPC protocol
◦ Two-message reliable IPC protocol
Four-message reliable IPC protocol
70
Four-message reliable IPC protocol
Sender’s Receiver’s
execution execution
request
acknowledgment
reply
Blocked state
acknowledgment
executing state
Three -message reliable IPC
protocol
The result of the processed request is sufficient
acknowledgment that the request message was
received by the server.
Three-message reliable IPC protocol
Sender’s Receiver’s
execution execution
request
reply
Blocked state
acknowledgment
executing state
Cont…
Problem is with timeout value.
• If the request message is lost, it will be
retransmitted only after the timeout period,
which might have been set to a larger value.
request
reply
Blocked state
executing state
Fault-tolerant communication
client server
Send Request message
request
timeout
lost
Send
request Retransmit
timeout Request message
Response message
Idempotency
It means repeatibility.
What Happens?
Cont…
Solution
◦ Use unique id for every REQ
◦ maintains a reply cache in the kernel’s address space
on the server machine to cache replies.
Closed group
◦ Only the members of the group can send a message
to the group.
Open group
◦ Any process in the system can send a message to the
group as a whole.
Cont… : group management
A message-passing system with group
communication facility provides the flexibility:
◦ to create and delete groups dynamically, &
◦ to allow a process to join or leave a group at any time.
Membership primitives
◦ e.g., join, leave, query_membership;
S1 R1 R2 S2
t1
m1 Time
t2
t1 < t2
m2
m1
m2
Consistent ordering
This semantics ensures that all messages are
delivered to all receiver processes in the same
order.
t1
Time
t2
m2 m2 t1 < t2
m1 m1
Cont…
Here, the sequencer-based method is subject to
single point of failure and hence has poor
reliability.
ABCAST protocol
1. The sender assigns a temporary sequence number to the message and sends it to all the members of the
multicast group. The sequence number assigned by the sender must be larger than any previous sequence number
used by the sender. Therefore, a simple counter can be used by the sender to assign sequence numbers to its
messages.
2. On receiving the message, each member of the group returns a proposed sequence number to the sender. A
member (i) calculates its proposed sequence number by using the function max(Fmax' Pmax) + 1 + ilN where Fmax
is the largest final sequence number agreed upon so far for a message received by the group (each member makes
a record of this when a final sequence number is agreed upon), Pmax is the largest proposed sequence number by
this member, and N is the total number of members in the multicast group.
3. When the sender has received the proposed sequence numbers from all the members, it selects the largest one
as the final sequence number for the message and sends it to all members in a commit message. The chosen final
sequence number is guaranteed to be unique because of the term UNin the function used for the calculation of a
proposed sequence number.
4. On receiving the commit message, each member attaches the final sequence number to the message.
5. Committed messages with final sequence numbers are delivered to the application programs in order of their
final sequence numbers. Note that the algorithm for sequence number assignment to a message is a part of the
runtime system, not the user processes
Causal Ordering
• PCR
CBCAST Protocol
• For Causal Ordering – USED in ISIS, a real commercial distributed
system, based on process groups.
• The ISIS project has moved from Cornell University to ISIS Distributed System a
subsidiary of Stratus Computer Inc.