The Building Blocks: Send and Receive Operations

 1   P0                         P1 
 2 
 3   a = 100;              receive(&a, 1, 0) 
 4   send(&a, 1, 1);       printf("%d\n", a); 
 5   a=0;
  
$\bullet$ Process $P_0$ sends a message to process $P_1$ which receives and prints the message.
$\bullet$ The important thing to note is that process $P_0$ changes the value of a to 0 immediately following the send.
$\bullet$ The semantics of the send operation require that the value received by process $P_1$ must be 100 (not 0).
$\bullet$ That is, the value of $a$ at the time of the send operation must be the value that is received by process $P_1$.
$\bullet$ It may seem that it is quite straightforward to ensure the semantics of the send and receive operations.
$\bullet$ However, based on how the send and receive operations are implemented this may not be the case.


Subsections