diff options
Diffstat (limited to 'ptw32_InterlockedCompareExchange.c')
-rw-r--r-- | ptw32_InterlockedCompareExchange.c | 16 |
1 files changed, 9 insertions, 7 deletions
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 |