[c++-pthreads] Initialization of local static mutex
Roland Schwarz
roland.schwarz at chello.at
Sun Oct 8 16:55:54 UTC 2006
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
More information about the c++-pthreads
mailing list