No, you don’t need a mutex for this. A call pthread_once( here ) is guaranteed to be executed once and only once, even if several threads try it at the same time.
This once_var, which protects the call from being executed more than once. It will work as expected, provided that you:
- enter
once_varin PTHREAD_ONCE_INIT; and - ,
once_var (, ); once_var.