I’d like to know how are mutex created on Linux? I figured out, that pthread_mutex_init() doesn’t change value of pthread_mutex_t variable, so how it “create” mutex?
Does it mark this variable as some kind of system resource or what?
I was implementing R-value constructor for class, which have a pthread_mutex_t field in it’s body and I don’t know how to move mutex frome one class to another…
You can see what pthread_mutex_init does here (warning, you brain will hurt).
It does memset() the mutex.
However, mutexes are implemented on top of the futex calls. This works on memory addresses, i.e.
the address of one of the pthread_mutex_t members is used as a system resource.
This means you cannot copy/move a pthread_mutex_t.