x86是否具有保持存储值的原子增量?

时间:2022-12-29 03:14:43

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.

我找到了lock inc addr,但是它没有保存存储值的副本,甚至在同一个线程中的读取之后立即读取也会在竞争写入之后。

The best solution I have found is a load/inc/cas loop.

我发现的最佳解决方案是load / inc / cas循环。

2 个解决方案

#1


11  

lock xadd is your friend.

锁xadd是你的朋友。

#2


3  

see atomic_impl.h for more x86/x86_64 atomic primitives and usage.

有关更多x86 / x86_64原子基元和用法,请参阅atomic_impl.h。

#1


11  

lock xadd is your friend.

锁xadd是你的朋友。

#2


3  

see atomic_impl.h for more x86/x86_64 atomic primitives and usage.

有关更多x86 / x86_64原子基元和用法,请参阅atomic_impl.h。