Distributed and Complex Systems Group : Homepage

:Vérimag Distributed and Complex Systems Group

BIP -- Incremental Component-based Construction of Real-time Systems

Producer-Consumer example

Download BIP code


The example consists of two components, a producer and a consumer, which can work independently and communicate with each other through a rendez-vous. They work and communicate alternately. We model their behavior as a generic atomic component named Worker, as shown below.






component Worker

  port incomplete communicate
  port complete work

   behavior
     initial to
COMM
     state WORK
       on communicate to COMM
     state COMM
       on work to WORK
  end
end







The Worker component consists of an incomplete port communicate, and a complete port work. It's behavior is represented by a transition system with two states, WORK and COMM.

The producer-consumer system is represented as a compound component Team, which instantiates two Worker's, namely a producer and a consumer . The connector Comm connects  the ports communicate of the producer and the consumer components. In addition, there are singleton connectors (i.e containing only one port) prodWork and consWork,  which consist of the work port of the respective components and do not need explicit synchronization.






component
  Team

  contains Worker producer, consumer
 connector  prodCons = producer.communicate, 
                                    consumer.communicate

     behavior
       
do {#  printf("Communicating\n"); #}
      end

 connector prodWork = producer.work
    behavior
      do {# printf("Producer working\n"); #}
    end

 connector consWork = consumer.work
    behavior
      do {# printf("Consumer working\n"); #}
    end







Steps to execute the application:


  To generate the C++ code for the application,
$ bipc -f prodcons.bip --genC-top Team   To compile the application,
$ make prodcons.bip.x   To run the execution,
$ prodcons.bip.x   Ctrl-C to terminate. 

 Back to examples