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



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