next up previous
Next: Xinu Low-Level Message Up: Message Passing Previous: Pipes

Selectivity of Receipt

A process may wish to receive information from a subset of the set of ports available for receipt. Systems differ in the amount of selectivity provided to a receiving process. Some allow a process to receive either from a particular port or all ports. Others allow a process to specify any subset of the set of all ports. Still others allow a process to peek at the value of incoming messages and make its decision to accept or reject messages based on the contents of messages.

Selection of a subset of ports is often specified as follows:

{\bf select}
	{\bf receive} <port>  ...
	{\bf receive} <port> ...
	...
	{\bf receive} <port> ...
{\bf end}
(We are assuming RPC here, with synchronous send) If none of the ports has a message, then the process blocks. If several ports have messages, then one port is chosen non-deterministically. If only one port has a message, then the corresponding receive is executed. Typically, a select is enclosed within a loop. Thus after servicing a request, a process can service another request.

Often a system allows a guard to be attached to an arm of the select. The guard is a boolean expression and the associated receive occurs only if the condition is true. The following example shows guarded receives in a `bounded buffer' process:

{\bf loop}
	{\bf select}
		{\bf when} count > 0 {\bf receive} consume (...) ...
		{\bf when} count < size {\bf receive} produce (...) ...
	{\bf end}
{\bf end loop}.
Here count keeps the number of filled buffers. The consuming process is blocked if the buffer is empty and the producing process is blocked if it is full.

Notice a process executing such a loop statement is similar to a monitor. Each receive in an arm of a select corresponds to an entry procedure declaration in a Monitor. A process services one receive at a time, just as a monitor executes one entry procedure at a time. The guards correspond to waits on conditions. The Lauer and Needham paper contains a more detailed discussion on this topic.


next up previous
Next: Xinu Low-Level Message Up: Message Passing Previous: Pipes



Prasun Dewan
Tue Sep 24 14:33:02 EDT 1996