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 等相关指令是因为它们构成了无锁解决方案的核心。
Note that the CMPXCHG instruction is atomic, which means that there is no intermediate visible state of the system before this instruction finishes.
注意,CMPXCHG指令是原子性的,这意味着在这个指令结束之前没有可见的中间状态。
应用推荐