Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Approaches to threading

Author: Sean Empey

Date: 09:36:08 06/16/04

Go up one level in this thread


On June 16, 2004 at 00:14:22, Sean Empey wrote:

>On June 15, 2004 at 19:10:33, Russell Reagan wrote:
>
>>On June 15, 2004 at 18:01:07, Sean Empey wrote:
>>
>>>Since you are writing it in C look at: _beginthread
>>
>>Actually, you should use _beginthreadex() and _endthreadex(). CreateThread()
>>links to the single threaded C run time libraries, while _beginthread() and
>>_beginthreadex() link to the multithreaded C run time libraries. If you know you
>>are using the C run time libraries, you should use _beginthreadex(). If you
>>think you aren't using the C run time libraries, you should still use
>>_beginthreadex(), because it is almost impossible to know for sure that some
>>other library isn't using the C run time library under the hood.
>>_beginthreadex() is to be preferred over _beginthread() because _beginthread()
>>can cause an unrecoverable race condition in some cases. To be safe, use
>>_beginthreadex() and _endthreadex().
>
>
>Which ever; use _beginthread or _beginthreadex (NOTE: _beginthreadex acts like
>CreateThread() more closely but, _endthreadex does not close the handle whereas
>_endthread does for _beginthread.). I use _beginthread without issue. Looking at
>docs on _beginthread will lead you to _beginthreadex. Since you only want an IO
>thread and a helper thread; I referred you to _beginthread. Use either one but
>stay away from CreateThread if you want to have better success at cross-platform
> use. I compiled Storm fine on a Unix box and Windows Box.


It's important to have an IO thread and a worker thread. But running on a multi
processor machine is not needed. If you only have a single thread; the engine
can't accept any input while it's thinking. You can look at it like a UI thread
and background thread. If I'm crunching numbers in the background I don't want
my GUI locked up until the background task has completed. If I need to stop it,
I don't want to have to close the app. It's really not too terribly difficult to
create and manage a worker thread. I didn't have too many problems implementing
it.



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.