Author: Anthony Cozzie
Date: 04:58:01 11/18/04
Go up one level in this thread
On November 18, 2004 at 07:36:58, Daniel Shawul wrote:
>i have made a wrapper class for the lock/unlock operations
>that i do at a struct SPLIT.
>SPLIT
>{
> //HANDLE lock;
> CRITICAL_SECTION cs;
> other data...
>}
> At codeguru site i read that critical sections are faster than
>mutexes.But for me they are *very very slower*. I am sure i am doing something
>wrong but don't know what?
>Another question is how profitable is using methods like InterLockedExchange,
>i mean going low level, for SMP chess engines?
>
>SPLIT::SPLIT()
>{
> //lock = CreateMutex(NULL,0,NULL);
> InitializeCriticalSection(& cs);
>}
>SPLIT::~SPLIT()
>{
> //CloseHandle();
> DeleteCriticalSection(& cs);
>}
>SPLIT::Lock()
>{
> //WaitForSingleObject(lock,INFINITE);
> EnterCriticalSection(& cs);
>}
>SPLIT::UnLock()
>{
> //ReleaseMutex(lock);
> LeaveCriticalSection(& cs);
>}
>
>best
>daniel
You want a spinlock, not a mutex/semaphore/criticalsection/other OS trick.
Split is supposed to be _cheap_. If you block on a critical section, the
processor may put your process into the idle queue and run something else.
Read my other post. You need to spend a few weeks 1) looking over the Crafty
code 2) reading the DTS paper 3) _thinking_ about your design and how you want
it to work and under what circumstances (2? 4? 8? 500? processors). IMHO,
writing a parallel chess program is one of _the toughest_ programming tasks out
there, and you are seriously underestimating it. I spent probably 6 weeks just
designing - and I threw out at least 10 designs - before I settled on what I
have. Then I spent 2 weeks implementing, and I'm still working races out of the
system 6 months later (it crashes once every few days right now). And this is
on only two processors!
anthony
This page took 0.02 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.