Message Passing Chapter 3
Message Passing Chapter 3
P1 P2
Send(message); Message
Execution suspended
Execution resumed
Send(acknowledgment)
Execution resumed Acknowledgment
Buffering
• Messages copying from the address space of
the sending process to the address space of the
receiving process
• If the receiving process is not ready to receive
messages, then it should be save for later usage
• The message buffering is related to
synchronization strategy
• The following are the buffering strategies
1. Null buffer or no buffer
2. Buffer with unbounded capacity
3. Single-message buffer
4. Finite-bound or multiple-message buffer
1. Null buffer (or no buffering)
There is no place to temporarily store the message
One of the following implementation strategies
used
The message remains in sender address space and
execution of send is delayed until the receiver executes
receive
The message is simply discarded and the timeout
mechanism is used to resend the message after a
timeout period
message
2. Single-Message buffer
A buffer capacity to store single message is used on the
receiver’s node
An application module may have at most one message
outstanding at a time
Single-message buffer strategy is to keep the message
ready for use at the location of the receiver
The request message is buffered on the receiver’s node
if the receiver is not ready to receive the message
The message buffer may either be located in the
kernel's address space or in the receiver process’s
address space
Sending Receiving
process Single-message process
buffer
message
Node boundary
3. Unbounded-capacity buffer
A sender does not wait for the receiver to be ready
An unbounded-capacity message buffer that can store
all unreceived messages
It assure that all the messages sent to the receiver will
be delivered
4. Finite-bound (or multiple-message) buffer
Asynchronous ode of communication use finite-bound
buffers
Need mechanism to handle the problem of buffer
overflow
Two ways to handle buffer overflow
Unsuccessful communication
Message transfers simply fail whenever there is no mode buffer
space
The send normally returns an error message to the sending process
This method is less reliable
Flow-controlled communication
The sender is blocked until the receiver accepts some messages
This method introduces a synchronization between sender and receiver
It result in unexpected deadlocks
the amount of buffer space to be allocated depends on
implementation
A create-buffer system call is provided to the users
The receiver mail box is located in the kernel address space
or in the receiver process address space
This buffering provides better concurrency and flexibility
message Message 1
Message 1
Multiple-message buffer/mailbox/port
Multidatagram Messages
• All networks has upper bound of the size of data
transmitted at a time
• This size is known as Maximum Transfer Unit(MTU) of a
network
• Message size greater than MTU has fragmented in to
multiples of the MTU
• Each fragment sent separately
• Each fragment is sent in a packet with control
information and data
• Each packet is known as datagram
• Messages smaller than the MTU of the network can be
sent in a single packet known as single-datagram
messages
• Messages larger than the MTU of the network have to be
fragmented and sent in multiple packets known as
multidatagram messages
Encoding and Decoding of Message Data
• The structure of program objects should be preserved ,
while transmitting from the address of the sending process
to receiving process
• Since both processes are on computers of different
architectures it is difficult
• Because two reasons
1. An absolute pointer value loses its meaning when transferred
from one address space to another
2. Different program objects occupy varying amount of storage
space, ex. Long int, short int, var size character strings
• Due to this problem the program objects first converted to a
stream form for transmission and placed into message
buffer
• This conversion process on the sender side is known as
encoding of a message data
• When received stream form converted to original program
objects
• Known as decoding.
• Two representations used for the encoding
and decoding
1. Tagged representation
The type of each program object along with its
value is encoded in the message
The receiving process to check the type of each
program object in the message
Program object is the self-describing nature of the
coded data format
2. Untagged representation
The message data only contains program objects
No information is included in the message data to
specify the type of each program object
Receiver process must have prior knowledge of
how to decode
Process Addressing
• MPS supports two types of process addressing
1. Explicit Addressing
The process with which communication is desired is
explicitly named as a parameter
Send(process_id, message) – send a message to the process
identified by process_id
Receive(process_id, message) – receive a message from the
process identified by process_id
2. Implicit Addressing
A process willing to communicate does not explicitly name
a process
Send_any(service_id, message)
Receive_any(process_id, message)
This type of primitive is useful in client-server
communications when the client request from set of server
provide services
This type of addressing is known as functional addressing
• The receiver is willing to accept a message from any
sender
• Two types of process addressing used in
communication primitives
1. Combination of machine_id and local_id such as
machine_id@local_id
The local_id part is a process identifier or a port identifier of a
receiving process
The machine_id part is used by the sending machines machines
kernel to send the message to the receiving process machine
2. Another method process identified by a combination of
three fields:machine_id, local_id, and machine_id
1st field identifies the node on which the process is created
2nd field is a local identifier generated by the node on which the
process is created
3rd field identifies the last known location (node) of the process
This method is known as link-based addressing
• Another method to achieve location
transparency is name server
• A processer wants to send a message to
another process specifies the high-level name
of the process
• This name is mapped with name server to get
its low-level names
• Using low-level name kernel sends the message
to the proper name
• The sending kernel also caches the high-level
name to low-level name receiving process
• For future use sending process need not
contact name server again
Failure Handling
• DS may suffer by partial failure like a node
crash or a communication link failure
• During interprocess communication following
failure problems will arise
Loss of request message
Due to the failure of communication link or receiver node
is down at the time the request reaches there
Sender Receiver
Send request
Lost
Loss of response message
Due to the communication link failure or the senders
node down
Sender Receiver
Send request Request message
Successful request
execution
Response message Send response
Lost
Unsuccessful request
execution
Restarted
• The kernel of the sending machine is
responsible for retransmitting the message
after waiting for a timeout period
• If the no acknowledgement is received
• The kernel of the sending machine frees the
sending process only when
acknowledgement is received
• The timeout value is slightly more than the
approximate round-trip time plus the
average time required for executing request
• Four-message IPC protocol for client server
communication between two processes
Client Server
Request
Acknowledgement
Reply
Acknowledgement
• In communication result of the processed
request is sufficient acknowledgement
• Using this three-message IPC protocol defined
Client Server
Request
Reply
Acknowledgement
• In the above protocol a problem occurs if a request
processing takes long time
• In this case the sender kernel timeouts and retransmit
the message
• To avoid unnecessary retransmission use separate
acknowledgement if processing takes long time
• Acknowledgement is not necessary because unnecessary
retransmission of the messages and request processing
• Use two-message IPC protocol
Client Server
Request
Reply
• Based on 2-msg IPC failure handling in
communication
Client Server
Send request Request message
Timeout
Lost
Send request Retransmit
Request message
Timeout
Unsuccessful
Retransmit Request execution
Send request Request message Crash
Restarted
Successful request execution
Timeout These two successful executions
Response message Send response of the same request
may produce different
Lost results
Send request Retransmit
Request message
Successful request execution
Response message
Idempotency and Handling of Duplicate Request Messages
• Idempotency means repeatability
• An idempotent operation produces the same results
without any side effects
• Example for idempotent routine GetSqrt(64) produces
the same value always 8.
• Operations which do not produce same results when
executed repeatedly with same arguments are
nonidempotent
• If the execution of the request is nonidempotent, then its
repeated execution will destroy the consistency of
information
• Such “orphan” executions must be avoided
• This orphan phenomenon use the exactly-once
semantics, which ensures only one execution is
performed by server
• It is difficult to implement
• Example of non idempotent execution
Server
Client (balance = 1000)
Send
request request Process debit routine
Debit(100) Balance = 1000-100=900)
Timeout Return(success, 900)
response
Lost (success, 900)
Send
request Retransmit request
(5, 10000)
Fifth of 5 packets Place this packet in position 5
(5, 01001)
Retransmit request for missing packets
Missing packet info
Resend (5, 00001)
missing First of 5 packets Place this packet in position 1
packets
(5, 01000)
Fourth of 5 packets
Place this packet in position 4
(5, 00000) Send acknowledgement
Acknowledgement