tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Semantics of copying mutex/rwlock

I've seen people state that making a copy of a mutex/rwlock and then
using that copy will give undefined results. Just trying to understand
why that happens.

As far as I know, NetBSD pthreads man pages don't talk about how
locking primitives are implemented and the result of copying them.

I mean, maybe it's conventional wisdom that you shouldn't make a copy
of a mutex, but it seems logical to think that if you have a mutex and
you know no threads are using it, then 

memcpy(&new_mutex, &old_mutex, sizeof(pthread_mutex_t))

and having all threads use new mutex should be OK?

Home | Main Index | Thread Index | Old Index