. - 2


 

producer()

{

message m;

int item;

 

while (TRUE)

{

produce_item(&item);

receive(consumer, &m, msize); /* */

/* "" */

build_message(&m, item); /* */

send(consumer, &m, msize);

}

}

 

consumer()

{

message m;

int item, i;

 

for (i = 0; i < N; i ++)

send (producer, &m, msize); /* *.

/* "" */

while (TRUE)

{

receive(producer, &m, msize);

extract_item(&m, item);

send(producer, &m, msize); /* "" */

consume_item(item);

}

}

 

producer() AND consumer() /* 2 */

 

 

. - (Dijkstra) "-".