next up previous
Next: About this document Up: Process Coordination Previous: Path Expressions

Synchronous Message Passing

Synchronous message passing offers another mechanism for process synchronization. To illustrate, a bounded buffer can be defined using message-passing primitives. The buffer is managed by a special ``bounded buffer'' process, with which producers and consumers communicate to produce and consume buffers, respectively:

loop
    select
        when count > 0 receive GetBuffer (...) ...
        when count < size receive PutBuffer (...) ...
    end
end loop.
Here we are assuming RPC, select, and guards. The process defines two input ports, one for producers and another for consumers, and uses select to receive both produce and consume requests. The variable count keeps the number of filled buffers. A consuming process is blocked if the buffer is empty and a 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 on duality of operatings system structures contains a more detailed discussion on this topic.



Prasun Dewan
Tue Feb 24 14:38:40 EST 2004