On Sun, Apr 26, 2020 at 1:31 AM Cholerae Hu <
chole...@gmail.com> wrote:
>
> Atomic.StoreX doesn't return the old value of the given pointer, so lock mov would work. Why do we use a xchg instead? It there any performance issue?
I assume that you are talking about Intel processors. Intel
processors do not have a lock mov instruction.
From the Intel architecture manual:
The LOCK prefix can be prepended only to the following
instructions and only to those forms
of the instructions where the destination operand is a memory
operand: ADD, ADC, AND,
BTC, BTR, BTS, CMPXCHG, CMPXCH8B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR,
XADD, and XCHG.
Ian