Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Separate Thread or plain Loop??

Author: Ralf Elvsén

Date: 07:47:53 12/18/01

Go up one level in this thread


On December 18, 2001 at 10:34:28, Steve Maughan wrote:

>Ralf,
>
>>This is what I would recommend. Sure, there will be a learning curve,
>>but you will learn something really useful. The multithreaded approach
>>will give a nicer program structure.
>
>Thanks for the input.  Apart from structure are there any other advantages to
>using a threaded method?  What will be the affect on speed?

The speed shouldn't be affected at all.
>
>As regards the implementation of the thread I can see that all of my events
>triggered by the engine will need to be syncronized (e.g. OnNextPly)

Not sure what you mean.

>but do I
>need to do anything special (syncronize?) with methods called by the interface
>e.g. when the opponent makes a move by calling PlayMove()

My input-output-only-thread lies blocked waiting for messages from
Xboard. If it needs to stop the search it does so by setting a variable
which also tells the search thread what it should do next (goto rest,
make a move and ponder etc). I have a couple of semaphores to ensure
there are no read/writes to datastructures from the two threads
simultaneously. This is because e.g. I let the IO-thread execute the
setposition-command. This can be worked around of course but it doesn't
bother me. I guess someone else can give a simpler design.

Ralf
>
>Thanks,
>
>Steve



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.