This is the mail archive of the pthreads-win32@sourceware.cygnus.com mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: pthread_cond_broadcast()


Lorin Hochstein wrote:

> [....]
> I tried to test this by writing a smaller program which just does this
> (attached to this e-mail). However, this smaller program seems to have
> even bigger problems, the threads never respond to the broadcast, and I
> have no clue why (it works just fine in Linux)! Could anybody offer any
> assistance?

First, you are locking mutex1 in one thread - main(), and unlocks it in thread
which did not lock it - thread1(), thread2().

Second, you uses mutex1 for pthread_cond_wait() call (without locking it first).

Third, it is advisable to call pthread_cond_signal() / pthread_cond_broadcast()
with the associated mutex locked, and pthreads-win32 requests this.

And - each time check pthread_*() return values, even in the test code!

Hope this helps you

Peter Slacik




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]