From 47d030b0ab9adf502451ef1558eeca50e67063c0 Mon Sep 17 00:00:00 2001 From: rpj Date: Sat, 12 Mar 2005 23:00:53 +0000 Subject: New design for pthread_once (with cancelability); ABI change --- ptw32_InterlockedCompareExchange.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'ptw32_InterlockedCompareExchange.c') diff --git a/ptw32_InterlockedCompareExchange.c b/ptw32_InterlockedCompareExchange.c index 581d19d..5ffc754 100644 --- a/ptw32_InterlockedCompareExchange.c +++ b/ptw32_InterlockedCompareExchange.c @@ -204,12 +204,13 @@ ptw32_InterlockedExchange (LPLONG location, * it doesn't lock the bus. If an interrupt or context switch * occurs between the MOV and the CMPXCHG then the value in * 'location' may have changed, in which case we will loop - * back to do the MOV again. Because both instructions - * reference the same location, they will not be re-ordered - * in the pipeline. + * back to do the MOV again. + * + * FIXME! Need memory barriers for the MOV+CMPXCHG combo? + * * Tests show that this routine has almost identical timing * to Win32's InterlockedExchange(), which is much faster than - * using the an inlined 'xchg' instruction, so it's probably + * using the inlined 'xchg' instruction above, so it's probably * doing something similar to this (on UP systems). * * Can we do without the PUSH/POP instructions? @@ -245,9 +246,10 @@ L1: MOV eax,dword ptr [ecx] * it doesn't lock the bus. If an interrupt or context switch * occurs between the movl and the cmpxchgl then the value in * 'location' may have changed, in which case we will loop - * back to do the movl again. Because both instructions - * reference the same location, they will not be re-ordered - * in the pipeline. + * back to do the movl again. + * + * FIXME! Need memory barriers for the MOV+CMPXCHG combo? + * * Tests show that this routine has almost identical timing * to Win32's InterlockedExchange(), which is much faster than * using the an inlined 'xchg' instruction, so it's probably -- cgit v1.2.3