Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: new questions

Author: Paul Clarke

Date: 03:28:56 11/19/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?

Assuming you're talking about Windows, critical sections are much faster than
mutexes _if_ there's no contention. Acquiring a critical section that no other
thread owns is a matter of a few instruction. However, if another thread has
already acquired the critsec then the current thread will have to wait on an
event associated with the critsec, making it roughly as slow as using a mutex.




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.