A classical bounded buffer composed of cells. The buffer is shared by a producer and a consumer. The producer can only write in an empty cell, and the consumer can only read a full cell. This version is deadlock free.
| Operating System | Path | Script name | Parameters |
| Unix | ProActive/scripts/unix/ |
buffer.sh |
None |
| Windows | ProActive/scripts/windows/ |
buffer.bat |
None |
public class Boundedbuffer implements Activepublic String put(String str) - Put a string in the next free cellpublic String get() - Get the content of the first free cellpublic class Producer implements Active
public void toggle() - Starts/Stops the producerpublic void done() - Signals the producer to kill himselfpublic class Consumer implements Active
public void toggle() - Starts/Stops the consumerpublic void done() - Signals the consumer to kill himselfpublic class ActiveDisplay implements Active
public void start() - Initializes the Active objectspublic voiddone() - Stops every active objectpublic void update(int pos,String str) - Sets the text of the cell pos to the value of strpublic void toggleCons() - Changes the states of the consumerpublic void toggleProd() - Changes the state of the produderpublic voidsetOut(int pos) - Sets the next cell to be written.public void setIn(int pos) - Sets the next cell to be read.
This class is responsible for the whole synchronization of the application. Here is the synchronization code:
The role of the producer is to fill the buffer's
cells with data [String] in a synchronous way. The producer will fill
one cell after another then pause for some time.
The role of the consumer is to empty the buffer's cells in a
synchronous way. The producer will read one cell after another then
pause for some time.
| Feel free to send any suggestions to proactive@objectweb.org © 2001-2007 Inria Sophia Antipolis |