Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does x86 have an atomic increment that keeps the value that was stored?

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.

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

like image 808
BCS Avatar asked Dec 09 '22 21:12

BCS


1 Answers

lock xadd is your friend.

like image 74
Anton Tykhyy Avatar answered May 14 '23 19:05

Anton Tykhyy