This is the mail archive of the
pthreads-win32@sourceware.cygnus.com
mailing list for the pthreas-win32 project.
Re: Pthreads over Win32 / Condition Variables (fwd)
- To: Ross Johnson <rpj at ise dot canberra dot edu dot au>
- Subject: Re: Pthreads over Win32 / Condition Variables (fwd)
- From: Peter Slacik <Peter dot Slacik at tatramed dot sk>
- Date: Fri, 15 Oct 1999 14:20:08 +0200
- Cc: Pthreads Developers List <pthreads-win32 at sourceware dot cygnus dot com>
- Organization: TatraMed s.r.o.
- References: <Pine.LNX.4.05.9910141750340.28647-100000@swan.canberra.edu.au>
Ross Johnson wrote:
> [...] looking at the code I've found another bug nearby.
>
> The internal routine Cond_timedwait, called by pthread_cond_wait and
> pthread_cond_timedwait, is a cancelation point. In case the thread
> is canceled while it's waiting, the code pushes a cleanup handler
> (actually just pthread_mutex_lock) to re-lock the mutex associated
> with the CV. At the moment this is all it does.
>
> The canceled waiting thread doesn't decrement the waiting threads
> count (cv->waiters) and so the count will never get back to zero,
> and the true last waiter will never notify the broadcasting thread.
>
> I suspect the cleanup handler also needs to check if a broadcast is
> in effect and if it's the last waiting thread, and finish off the
> broadcast if it is.
Lorin Hochstein <lmh@xiphos.ca> already informed about this problem (Wed, 30 Jun
1999) and submitted a bugfix. Ross, please check my reply (Thu, 01 Jul 1999)
too.
--
Peter Slacik