This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: pthread_cond_wait
- From: Gilles Carry <Gilles dot Carry at bull dot net>
- To: Polina Dudnik <pdudnik at cs dot wisc dot edu>
- Cc: libc-help at sourceware dot org
- Date: Wed, 09 Jul 2008 09:50:07 +0200
- Subject: Re: pthread_cond_wait
- References: <487384BD.3060600@cs.wisc.edu>
Polina Dudnik wrote:
Hi,
I would like to write my own version of pthread_cond_wait, which doesn't
have a mutex as one of it's parameters, to be used with transactional
memory model. I am not sure why it is important to have the mutex locked
before calling lll_lock (cond->__data.__lock, pshared). What would
happen if the mutex was unlocked before calling lll_lock
(cond->__data.__lock, pshared). Thanks.
Hi,
As far as I remember, the external mutex is to avoid loss of signals.
Releasing the external mutex before the internal one would let a time window
in which a signal could be issued before the waiter is put into the waiting queue.
Anyway, before modifying pthread_cond_* stuff, you should carefully read this:
http://www.opengroup.org/onlinepubs/009695399/functions/pthread_cond_wait.html
and especially "Features of Mutexes and Condition Variables".
Hope this helps.
Gilles.