BIP -- Incremental Component-based Construction of Real-time Systems
A Producer-Consumer example with FIFO channel
This model is similar to the producer-consumer
example, with the additional fact that
the producer and consumer communicates through a fifo channel. The
producer transmits a
finite string, sending one character at a time to the fifo. The
consumer gets one character at
a time from the fifo and
prints them.
The fifo channel is
implemented as a component. It has a store
(an array of character) to accumulate the
characters sent by the producer.
The store has a finite size,
so when it is full, the producer
is blocked ,
similarly when it is empty, the consumer
is blocked. It is
described as follows:
The system Team consists of
instances of each of a producer,
consumer and fifo, and connectors C1 and C2 as
shown below. Both
connectors represent strong synchronization of the producer and the consumer with the fifo.
The system on execution displays the characters in the sequence
as they are
received by the consumer. The producer terminates after it has sent the
string to the fifo. Finally the consumer
also terminates once it has received all the characters from the fifo and the system terminates to a
deadlock.
Steps to execute the application:
To generate the C++ code for the application,
$ bipc -f fifo.bip --genC-top Team
To compile the application,
$ make fifo.bip.x
To run the execution,
$ fifo.bip.x -quiet