Messages

The most 'obvious' means of inter-process communication, perhaps, are messages. A message is a block of data which one process may send to another. In the most general case, messages may be of any length and are unstructured---the sender and receiver between them decide how the bytes of the message should be interpreted.

An important concept  with messages is the port (or message port, just to be unambiguous). The port is the data structure to which messages are sent. In some systems, there may be only one port per process, and it is convenient to talk of the messages being sent directly to the process, but in the general case, a process may own several ports, and receive messages from any of them.

Typically the system provides two main system calls, SEND and RECEIVE. Since RECEIVE typically blocks if there are no messages waiting at the receiver's message port, there will often be another system call to check for messages without blocking.

In a typical implementation, the receiving port maintains a strict queue of messages which have been received. It also contains a semaphore, or some kind of signal information, so that the receiving process may block while waiting for messages.

Alternatively, the port does not queue messages, but the sender and receiver synchronize their send and receive operations. If the sender sends before the receiver is ready, the sender blocks. If the receiver receives before the sender has tried to send, the receiver blocks (as before). In this scheme, the sender and receiver are tightly coupled. Known as a rendezvous, and less flexible than when messages are buffered.


last updated 31 April 1998