Author: Robert Hyatt
Date: 08:01:41 03/09/02
Go up one level in this thread
On March 08, 2002 at 15:58:50, Sune Fischer wrote: >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. > You can kill the thread. you can set a global variable (in Crafty, abort_search=1) and at the top of Search() you check for this flag and back out if it is set... > >>>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.