在x86上,如果mem是32位对齐的,则mov操作保证是原子的.
如果[mem]不是32位对齐,可以锁定inc [mem] sill工作正常吗?
工作正常:提供原子性而不是获得部分价值.
解决方法
x86和x64的
Intel Instruction Set Reference没有提到INC指令的对齐要求.所有关于LOCK的说法都是:
This instruction can be used with a LOCK prefix
to allow the instruction to be executed atomically.
LOCK前缀文档说明:
The integrity of the LOCK prefix is not affected by the alignment of the memory field. Memory locking is observed for arbitrarily misaligned fields.