> -----Original Message-----
> From: Michael Labhard [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 17, 2002 10:51 PM
> To: [EMAIL PROTECTED]
> Subject: Re: pthread_cond_wait does not relock mutex on release
>
>
> Robert and Gerald:
>
> Both quite right. Although adding the SAFE_PRINTF made no
> difference in the
> output, checking a condition value in a loop made all the
> difference.
> Putting a printf in the loop revealed to my surprise that
> "spurious wakeups"
> were occurring thousands of times per second. I had naively
> assumed that a
> condition would stay set until signalled. Now I'm led to wonder if a
> condition variable is any performance improvement over a
> simple loop and
> short sleep. Any thoughts?
Without knowing what you are trying to achieve, I can't comment. However: in
multi-threaded programs, a condition variable will almost invariably be more efficient
than a loop + sleep.
As for conditions staying set, that isn't the purpose of condition variables: they are
designed to allow signalling between threads, to allow efficient use of cpu resources
- and to avoid that loop+sleep approach.
Rob
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/