mutex performance

Petri Helenius pete at he.iki.fi
Fri Nov 19 00:07:20 PST 2004


Niall Douglas wrote:

>In my library TnFOX (http://www.nedprod.com/TnFOX/) where I've 
>completely rewritten mutexs for speed:
>
>                        FXAtomicInt   FXMutex
>    SMP Build, 1 thread :  51203277  18389113
>    SMP Build, 2 threads:   4793978   5337603
>Non-SMP Build, 1 thread : 103305785  27352297
>Non-SMP Build, 2 threads:  54929964  10978153
>
>This is on a dual Athon 1700 (1.43Ghz), so that's 77.76 cycles per 
>lock/unlock with SMP build and 52.28 cycles on non-SMP build. The 
>difference between SMP and non-SMP is that the former uses the lock 
>prefix on the x86 instructions.
>
>So yes, I think there is some scope for improvement.
>  
>
Are these mutexes spinlocks or "real" locks which make the thread 
actually yield if they have to wait longer? Or should I RTFS? :-)

Pete



More information about the freebsd-threads mailing list