Does Interlocked.CompareExchange (double, double, double) support 32-bit OS?

I maintain a high performance class that can be controlled by multiple threads. Many of the fields are volatile ints, and as it turns out, I need to update one of them to double. I am curious if there is a blocking method for this, and wondered if it works Interlocked.CompareExchange(double, double, double)as advertised on a 32-bit OS or breaks, reads the problem.

+3
source share
3 answers

This page details the built-in locking features. It refers to the following limitations.

_InterlockedCompareExchange64 cmpxchg8b, pre-Pentium, 486.

, , ( ).

+2

, , 32- . , Interlocked.

+1

, .

InterlockedCompareExchange64 - x86 asm, - http://qc.embarcadero.com/wc/qcmain.aspx?d=6212.

asm
//     ->          EAX     Destination 
//                 ESP+4   Exchange    
//                 ESP+12  Comperand   
//     <-          EDX:EAX Result      
          PUSH    EBX
          PUSH    EDI

          MOV     EDI, EAX

          MOV     EAX, DWORD PTR [Comperand]
          MOV     EDX, DWORD PTR [Comperand+4]

          MOV     EBX, DWORD PTR [Exchange]
          MOV     ECX, DWORD PTR [Exchange+4]

LOCK      CMPXCHG8B [EDI]

          POP     EDI
          POP     EBX
end;
0

Source: https://habr.com/ru/post/1725968/


All Articles