Boost logo

Boost :

From: John Zorko (jmzorko_at_[hidden])
Date: 2007-06-26 15:58:59


Hello, all ...

We use Boost 1.34 in our project to provide crucial code portability
between Windows, Mac OSX and Linux. However, we've run into
something that doesn't seem to make sense according to the Boost
documentation. Consider the following very simple program:

#include "stdafx.h"
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <iostream>

boost::mutex g_Mutex;

void f1()
{
         boost::mutex::scoped_lock lock( g_Mutex );

         std::cout << "1\n";
}

int main(int argc, char* argv[])
{
         boost::mutex::scoped_lock lock( g_Mutex );

         std::cout << "main\n";

         f1();

         return 0;
}

... under Windows XP SP2 (using VC 8.0), the output is this:

main
1

... however, under Mac OSX 10.4.10 (using Apple's gcc4.0.1), the
output is:

main
(program hangs)

The code hangs on OSX when trying to grab the mutex again in the f1()
function. The Boost documentation for scoped_lock seems to say that
this should not be. I'm about to test the code on Linux (Gentoo x86)
as well, but i'm waiting for Boost to finish building on it.

Do I not understand boost::mutex::scoped_lock? Or is this a bug?

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk