|
What's the primary difference between calling someone on the phone and sending them a letter ... besides the cost of the stamp, I mean? A letter is a "write-it-send-it-forget-it" style of communication, while the phone only works if both parties synchronize their activities: you call, I answer, you talk, I listen, I talk, you talk ... no, wait, you're not my mother: I talk, you listen. This characteristic of synchronization is what distinguishes blocking-style communications from non-blocking: phone calls are blocking, because neither of us does anything until we're each of us ready on our side of the connection; letters are non-blocking, because I've already forgotten about it almost before I mailed it, and you aren't going to get it for days, and even then you probably won't read it.
- Synchronous
Just like phone calls, blocking-style communications only operate when both sender and receiver are ready to cooperate in the activity. This can have both positive and negative implications, depending on the context of the situation.
- send: return only after receipt of acknowledgement from the remote receiver that the receive operation has actually begun
The act of transmission is not considered complete, in a synchronous sense, until the receiver-side has sent back an indication that the receive process has actually begun ... not completed, simply begun; it's likely that this disparity exists for two reasons:
- once the receive has started, it's unlikely that anything is going to keep it from finishing, and
- the time it takes to get the acknowledgment back to the sender will likely leave the two processes more closely synchronized than if the receiver had waited until the operation were completed before acknowledging.
- receive: return after message is completely received (i.e. entire valid copy of message exists in user supplied buffer)
The receive side doesn't return until the information it's waiting for is ready for the process to begin using.
- Features:
Synchronous communications are both indispensable and potentially hazardous:
- Strongest temporal synchronization protocol for point-to-point communications
There is no better way to achieve inter-process synchronization than the use of blocking sends/receives; however ...
- Can lead to unnecessary delays if receives are not posted before sends
They have to be used correctly, or (sometime severe) inefficiencies can result. The best way to deal with blocking communications is to always have the receive side waiting for the phone to ring: among other things, this guarantees that all buffer allocation has been done prior to the messages' arrival so that the sender isn't forced to wait for that sometimes lengthy transaction to be accomplished.
|