When to use pthread_mutex_t

The pthread_mutex_t is a POSIX solution (available for linux and other UNIX systems) that existed before c++11 introduced synchronisation primitives into the c++ library. You should use std::mutex now, amongst other things it is more cross-platform (can be used under Windows also).


std::mutex is just a thin wrapper around pthread_mutex on systems supporting pthreads.

In general, the operations on the std:: thread primitives are quite limited vs the native versions (pthreads or windows threads). If you don't need those features, you should always use the std:: versions, but if you do need the advanced features, then you have no choice but to use the native version.

native handle() method exists for exactly this reason.