如何在 x86 中实现 128 位原子操作?
英特尔系统编程指南,第 1 部分,8.1 锁定原子操作指定有保证的 16 位、32 位和 64 位原子操作。那么,可以通过执行 2 个带有 LOCK 前缀的 64 位操作来实现 128 位原子操作吗?类似...
LOCK mov 64bits->addr
LOCK mov 64bits->addr+64bits
显然,SSE 有 128 位 XMM 寄存器。您可以使用这些寄存器进行 128 位比较和交换吗?
最佳答案
LOCK
前缀不能与MOV
指令结合使用。
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. Intel Instruction Set Reference
这样做将生成无效操作码异常。所以LOCK CMPXCHG16B
是这里唯一的方法。
关于assembly - x86 128 位原子操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4099002/