Chapter 10. Message Passing
In previous chapters, we have seen that when threads interact through shared variables, these variables must be encapsulated in monitor objects to ensure correct behavior. An alternative way of organizing concurrent programs which does not require shared variables is to use message passing. In message-passing programs, processes interact by sending and receiving messages. Processes that interact solely by message exchange do not need to access shared memory and consequently can be located on different computers connected by a communication network. However, message passing is also frequently used when processes are intended to run within a single computer.
Fundamental to message passing are the operations to send and receive a message. There are a surprising number of different definitions for these operations in message-passing systems. We examine the two basic models for message passing: synchronous message passing, in which the sender of a message waits until it has been received; and asynchronous message passing, in which the sender does not wait and messages which have been sent but not yet received are buffered. These are both one-way forms of communication: the messages are transmitted in one direction only, from sender to receiver. In addition, we examine the rendezvous, a two-way message-passing protocol used for client–server interaction.
Synchronous Message Passing
An important design decision in a message-passing scheme is how to designate the ...
Get Concurrency: State Models and Java Programs now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.