boundedbuffer
This is an old revision of the document!
How do you implement a bounded FIFO buffer in C-Linda? Assume the buffer contains integers (to make life a little easier). There are a number of producers and a number of consumer. Assume that the functions consume and produce have already been defined. Now consider the functions consumer and producer.
void consumer() { int data; while (1) { data = get(); consume(data); } } void producer() { int data; while (1) { data = produce(); put(data); } }
A single consumer and producer can be created as follows.
void real_main() { eval("consumer", consumer()); eval("producer", producer()); }
How can the above be extended to create multiple consumers and producers?
It remains to define the functions get and put.
int get() { int data; return data; } void put(int data) { }
How should get and put be completed?
boundedbuffer.1190251524.txt.gz · Last modified: 2007/09/20 01:25 by franck