Author: Robert Hyatt
Date: 07:48:53 12/01/03
Go up one level in this thread
On December 01, 2003 at 10:11:02, Andreas Guettinger wrote:
>On December 01, 2003 at 04:55:31, Tony Werten wrote:
>
>>On December 01, 2003 at 04:50:20, Andreas Guettinger wrote:
>>
>>>On December 01, 2003 at 02:41:28, Tony Werten wrote:
>>>
>>>>When my masterthread is spinning, waiting for results from it's workers threads,
>>>>how do I keep it from burning CPU time ?
>>>>
>>>>The apifunction sleep() doesn't some threadsafe, suspending the thread and
>>>>having it resumed by the worker seems overly complicated. ( Accept maybe if I
>>>>can use a callback function )
>>>>
>>>>Any thoughts ?
>>>>
>>>>Tony
>>>
>>>Isn't that what condition variables are for?
>>
>>Yes, but the looping costs processor time. I want to get rid of that.
>>
>>Preferably:
>>
>>While (no_results) do request('Dear mr Operating System. Don't spend any time on
>>me since I'm not doing anything usefull anyway. Please spend the remaining of
>>this timeslice on my workers since I can't do anything until they are finished.
>>Your's truly, Main Thread' :)
>>
>>Tony
>>
>>>
>>>regards
>>>Andy
>
>
>I don't get it.
>
>pthread_cond_wait()
>pthread_cond_timedwait()
>
>are using CPU time when the thread is blocked? This should not be:
No. I believe he misunderstood what "condition variables" are. He was
thinking of a spin-variable instead...
>
>http://www.die.net/doc/linux/man/man3/pthread_cond_wait.3.html
>
>"pthread_cond_wait atomically unlocks the mutex (as per pthread_unlock_mutex)
>and waits for the condition variablecond to be signaled. The thread execution is
>suspended and does not consume any CPU time until the condition variable is
>signaled. The mutex must be locked by the calling thread on entrance to
>pthread_cond_wait. Before returning to the calling thread, pthread_cond_wait
>re-acquires mutex (as per pthread_lock_mutex)."
>
>regards
>Andy
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.