why not call pthread_mutex_lock() after pthread_mutex_init(), this is not atomic but as you're in the initialization phase, only one thread/process is doing it, right? this is done once