The Building Blocks: Send and Receive Operations
- Since interactions are accomplished by sending and receiving messages, the basic operations in the message-passing programming paradigm are send and receive.
- In their simplest form, the prototypes of these operations are defined as follows:
- sendbuf points to a buffer that stores the data to be sent,
- recvbuf points to a buffer that stores the data to be received,
- nelems is the number of data units to be sent and received,
- dest is the identifier of the process that receives the data,
- source is the identifier of the process that sends the data.
- Process sends a message to process which receives and prints the message.
- The important thing to note is that process changes the value of a to 0 immediately following the send.
- The semantics of the send operation require that the value received by process must be 100 (not 0).
- That is, the value of at the time of the send operation must be the value that is received by process .
- It may seem that it is quite straightforward to ensure the semantics of the send and receive operations.
- However, based on how the send and receive operations are implemented this may not be the case.
- Most message passing platforms have additional hardware support for sending and receiving messages.
- They may support DMA (direct memory access) and asynchronous message transfer using network interface hardware.
- Network interfaces allow the transfer of messages from buffer memory to desired location without CPU intervention.
- Similarly, DMA allows copying of data from one memory location to another (e.g., communication buffers) without CPU support (once they have been programmed).
- As a result, if the send operation programs the communication hardware and returns before the communication operation has been accomplished, process might receive the value 0 in a instead of 100!
Subsections
Cem Ozdogan
2010-12-27