加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

多线程 – 在x86上如果[mem]不是32位对齐,可以“锁定inc [mem]”

发布时间:2020-12-14 05:43:24 所属栏目:Java 来源:网络整理
导读:在x86上,如果mem是32位对齐的,则mov操作保证是原子的. 如果[mem]不是32位对齐,可以锁定inc [mem] sill工作正常吗? 工作正常:提供原子性而不是获得部分价值. 解决方法 x86和x64的 Intel Instruction Set Reference没有提到INC指令的对齐要求.所有关于LOCK的
在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读