<b>(a)</b> // Assume R==0 on entry // Fill message buffer for( int i=0; i<n; i++) M[i] = ...; // Signal that message is ready. R = 1; <b>(b)</b> // Assume R==0 on entry // Wait for signal from sender while( R==0 ) continue // Read the message for( int i=0; i<n; i++ ) ... = M[i];
Example 1: (a) Code for sending a message; (b) code for receiving a message. Code assumes sequential consistency.