Re: [c++-pthreads] Initialization of local static mutex
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [c++-pthreads] Initialization of local static mutex
- To: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
- Subject: Re: [c++-pthreads] Initialization of local static mutex
- From: Roland Schwarz <roland.schwarz@xxxxxxxxx>
- Date: Sun, 08 Oct 2006 18:55:54 +0200
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.
I believe your code is thread-safe in practice for the particular case
of PTHREAD_MUTEX_INITIALIZER.
I am still afraid, that behavior is implementation dependent, and
would be glad if someone could _prove_ me wrong. (I don't think believe
is enough.)
Roland