Boost logo

Boost :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2007-08-21 15:33:30

Doug Gregor wrote:
> The problem only seems to occur on PowerPC Mac, because the test is
> running fine on my Intel Mac. There's a gdb dump of the backtraces
> for all running threads below.

Removed from SVN.

The main problem is that Mac does not have process-shared
barrier/mutexes/condition variables and an emulation using spinlocks is
used. Since my knowledge about atomic operations is *zero* my
implementation of interprocess_condition might be wrong or just the
atomic operations I'm using are not correctly implemented.

I guess I should ask Boost thread-experts (Boost.Thread maintainers
willing to help?) to write these synchronization primitives for me
or/and beg for a simple atomic operation package in Boost. At least some
that implement increment, cas, decrement, atomic read and read (full
barrier semantics are enough for me, I just don't understand what
acquire and release are ;-) ).

The implementation of the emulated barrier is pretty simple:

inline barrier::barrier(unsigned int count)
    : m_threshold(count), m_count(count), m_generation(0)
    if (count == 0)
       throw std::invalid_argument("count cannot be zero.");

inline bool barrier::wait()
    scoped_lock<interprocess_mutex> lock(m_mutex);
    unsigned int gen = m_generation;

    if (--m_count == 0){
       m_count = m_threshold;
       return true;

    while (gen == m_generation){
    return false;

so I guess there is problem with my emulated condition implementation or
with atomic operations (which are taken from apache run-time library).



Boost list run by bdawes at, gregod at, cpdaniel at, john at