Does x86 have an atomic increment preserving the value that was saved?

I found lock inc addr , but it doesnโ€™t save a copy of the stored value around and even read it right after it could arrive in the same stream after a competing write.

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

+4
source share
2 answers

lock xadd is your friend.

+11
source

see atomic_impl.h for more primitives and using x86 / x86_64.

+3
source

Source: https://habr.com/ru/post/1274700/


All Articles