tech-userlevel archive

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

Re: Semantics of copying mutex/rwlock



In article <20100616144637.b88af2c1.cryintothebluesky%googlemail.com@localhost>,
Sad Clouds  <cryintothebluesky%googlemail.com@localhost> wrote:
>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?

Why do it in the first place? What are you doing with the old mutex?

christos



Home | Main Index | Thread Index | Old Index