[c++-pthreads] Initialization of local static mutex
Mark Mitchell
mark at codesourcery.com
Sun Oct 8 17:00:49 UTC 2006
Roland Schwarz wrote:
> Mark Mitchell wrote:
>> PTHREAD_MUTEX_INITIALIZER is supposed to be a constant-expression
>> (like "-1" or "{ 1, 0 }"), so the initialization will happen before
>> foo is called, typically at program start-up.
>
> This was not my question, or concern. I am not asking what is typical,
> but if it is possible that a standard conforming compiler can suffer
> from such a race condition.
A standard-conforming compiler, used with a standard-conforming POSIX
library, cannot suffer from a race condition in the code that you posted
because PTHREAD_MUTEX_INITIALIZER must be a constant-expression.
--
Mark Mitchell
CodeSourcery
mark at codesourcery.com
(650) 331-3385 x713
More information about the c++-pthreads
mailing list