Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-08-19 16:07:08


Wow, quite a flurry about CVs :) Been on the road the last two days...

About the CV problem... I don't think there is a problem. The calling
thread does not have to own the mutex to call notify(), at least it
doesn't in pthreads. From the POSIX standard, p.1045:

"The pthread_cond_broadcast() or pthread_cond_signal() function
may be called by a thread whether or not it currently owns the
mutex that threads calling pthread_cond_wait() or
pthread_cond_timedwait() have associated with the condition
variable during their waits"

In addition, I've read that calling notify() outside of the
critical section can decrease unwanted contention.
In "Multithreaded programming with Pthreads", p.98:

"The most obvious solution for at least some of this problem
is to make the call to signal or broadcast outside of the
critical section. This is what all of our code does."

Perhaps the problem came from how you were implementing CVs
on Win32?

Cheers,

Jeremy

William Kempf writes:
> The problem with the CV is that we've only insured that the
> associated mutex is locked in the call to wait() but not in the call
> to notify(). It would be nice if we could have some manner in which
> we can insure that we've locked the mutex at compile time for both of
> these, though I think we'll likely have to settle for an exception at
> run time. If you've seen Jeremy's documentation maybe you have some
> thoughts on this?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk