Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Chris Thomasson Date : Mon Apr 18 2005 09:49 am > "Should" and "possibly" aside, which one is faster mfence is faster than LOCK. > and by what margin? ;-) Go ahead and try running the following code on your system: #include #include #include #define LOOPS 500000000 int main() { int i; DWORD f, s; /* lock prefix */ s = GetTickCount(); for ( i = 0; i < LOOPS; ++i ) { __asm__ __volatile__ ("lock; addl $0, 0(%esp)"); } f = GetTickCount(); printf( "lock prefix time: %d\n", f - s ); /* mfence */ s = GetTickCount(); for ( i = 0; i < LOOPS; ++i ) { __asm__ __volatile__ ("addl $0, 0(%esp)\r\n mfence"); } f = GetTickCount(); printf( "mfence time: %d\n", f - s ); system( "pause" ); return 0; } .