Below is an illustration (pseudocode) of the Producer-Consumer programs using message passing:
Producer-Consumer programs using message passing. Taken from Bell, John T. "Processes." University of Illinois, Chicago.