MUC - Martin Ferrari and Remigiusz Modrzejewski


In parallel computing, a barrier is a type of synchronization method. A barrier for a group of threads or processes in the source code means any thread/process must stop at this point and cannot proceed until all other threads/processes reach this barrier.


The barrier is implemented as proved code in the Lustre language. The barrier itself is expressed as the synchronous code:

node LameBarrier(A: bool; B: bool) returns (C: bool);
var pA, pB: bool;
    pA = (not(pre(C)) and (false -> pre(pA)) or A);
    pB = (not(pre(C)) and (false -> pre(pB)) or B);
    C = pA and pB;

It is exported to WComp as an EventedBean in ProvedBarrier class.

The lustre code, plus glue code for the shared library, a test program and a Makefile are contained in the following tarball


To install the ProvedBarrier you need to download both native dll and .Net assembly. Then you add them to your setup as described in the tutorial.

You put it into your Container as a standard bean, found under Basic type of Beans.

The interface is declared as:

 public event ContinueHandler Continue;
 public void InputA()
 public void InputB()

Where Continue is the event that barrier emits once all the threads reached the synchronization point. InputA and InputB are the two events that indicate to the barrier that a thread has reached it. Multiple signals on a single input will be ignored.

There are additional public properties. They are there just for debug purposes. Once you choose your barrier in the IDE, you can see
the amount of threads that entered the barrier.

Simple Example

In this simple example you can chceck manually that the barrier works as advertised.


Once both threads reach barrier (both buttons are pressed) the barrier allows the threads to continue (another cycle will be counted and displayed on the label).

Download source code

Advanced Example

In this example the barrier is used to synchronize the two timers running at different speeds. Additionally full cycles are counted.


You press the button on the left to start the experiment. Timers will start working at different speeds what will be visible on the labels on the right. Counters are running in modulo 100 and will make their parts of construction enter barrier on Carry. Once both counters enter barrier the Continue signal will make the Timers to Start again. This usually works at least a few times before Timers throw thread exceptions. Finally on the center right label you see the amount of Full cycles - the number of synchronizations that happened.

Download source code

Unclear, need to ask the teachers, since most is obviously derived works.