Am 10/25/2011 16:55, schrieb Erik Faye-Lund: > +int pthread_mutex_lock(pthread_mutex_t *mutex) > +{ > + if (mutex->autoinit) { > + if (InterlockedCompareExchange(&mutex->autoinit, -1, 1) != -1) { > + pthread_mutex_init(mutex, NULL); > + mutex->autoinit = 0; > + } else > + while (mutex->autoinit != 0) > + ; /* wait for other thread */ > + } The double-checked locking idiom. Very suspicious. Can you explain why it works in this case? Why are no Interlocked functions needed for the other accesses of autoinit? ("It is volatile" is the wrong answer to this last question, BTW.) -- Hannes -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html