本文介绍了x86是否具有原子增量来保留存储的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发现了lock inc addr
,但这并不能保留存储的值的副本,甚至在竞争写入之后也会在同一线程中立即读取它.
I have found lock inc addr
but that doesn't keep a copy of the stored value around and even a read immediately after it in the same thread could come after a competing write.
我找到的最佳解决方案是load
/inc
/ cas
循环.
The best solution I have found is a load
/inc
/cas
loop.
推荐答案
lock xadd
是你的朋友.
这篇关于x86是否具有原子增量来保留存储的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!