Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Approaches to threading

Author: Sean Empey

Date: 21:14:22 06/15/04

Go up one level in this thread


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.



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.