Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Hey, I do that!

Author: Sune Fischer

Date: 12:58:50 03/08/02

Go up one level in this thread


On March 08, 2002 at 15:15:34, Miguel A. Ballicora wrote:

I have a related question about this polling thing.

How does one exit the searching thread cleanly when the polling thread finds a
command, like a move from the opponent that requires the search to stop?
I don't know a whole lot about threads, but is it possible to kill the thread
cleanly, so will it clean up all the garbage of memory allocations done in the
search?
Since it is a recursive function one obviously cannot just call return to get
out.
Is there a way around this if one does not use threads (yet)?

-S.


>>But in this case, the thread fulfills it own condition, i.e. the polling thread
>>calls fgets() and doesn't do anything until it gets it.  The only interaction
>>with the main thread is when the main thread checks the inputWaiting flag.  So
>>it doesn't seem like mutexes or semaphores would apply, according to your brief
>>description. (Then again, what do I know...)
>>
>>btw, I am compiling with the Borland C++ free compiler right now, if that
>>affects anyone's response.
>
>I do not like this design, but it is a matter of taste. Hhowever, if you are
>looking for solution try to introduce in the loop sleep(x) when x is IIRC
>miliseconds where the thread will sit doing nothing. So, if you do
>sleep(100) the thread will poll every 0.1 seconds and will consume almost
>no cpu.
>
>Regards,
>Miguel
>
>will
>you can int



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.