Author: James CE Johnson

ACE Tutorial 017
Using the ACE_Barrier synch object

The ACE_Barrier implements the barrier synchronization pattern.

That's nice. What does it mean?

What it means is that you can use the ACE_Barrier to cause a set of threads to all wait at a specific point in your application. In other words: the threads reach a barrier that none can pass until all are present.

This would typically be used in scientific applications where a set of threads are all working in parallel on some great computation but they have to synch and summarize before continuing to the next stage of calculation. With proper use of ACE_Barrier, the threads can easily synch before continuing.

In this tutorial I'll create a simple wrapper for the ACE_Barrier. In reality, the ACE_Barrier is so easy that a wrapper isn't really needed. I created the wrapper anyway though just because I wanted to.

Kirthika's abstract:

The ACE_Barrier class is used for collective thread syncronisation. All the threads block at the barrier and advance only after everyone is at the barrier. A thread blocks by calling the wait() method and stays until all the other threads invoke wait() one-by-one at the barrier and then all move ahead. Here, an abstract barrier class is created which incorporates the ACE_Barrier mechanism and is used in a test case of an ACE_Task with 10 and 5 threads respectively which illustrate the use of the barrier pattern.

[Tutorial Index] [Continue This Tutorial]