On Intel processors, compare-and-swap is implemented by the CMPXCHG family of instructions.
在Intel处理器中,比较并交换通过指令的cmpxchg系列实现。
You need to understand CMPXCHG and related instructions like CMPXCHG8B well, because they form the crux of lock-free solutions.
需要了解CMPXCHG和CMPXCHG8B 等相关指令是因为它们构成了无锁解决方案的核心。
You might find them by inspecting your binary for the typical spin-lock pattern at your system, e. g. , loop: CMPXCHG <adr>, JRZ loop.
你可能会发现他们通过检查你的系统二进制为典型的旋转锁模式,例如,loop:CMPXCHG <adr>,JRZ loop 。
Note that the CMPXCHG instruction is atomic, which means that there is no intermediate visible state of the system before this instruction finishes.
注意,CMPXCHG指令是原子性的,这意味着在这个指令结束之前没有可见的中间状态。
Note that the CMPXCHG instruction is atomic, which means that there is no intermediate visible state of the system before this instruction finishes.
注意,CMPXCHG指令是原子性的,这意味着在这个指令结束之前没有可见的中间状态。
应用推荐