BCS
BCS

Reputation: 78536

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.

Upvotes: 4

Views: 2527

Answers (2)

Test
Test

Reputation: 1727

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

Upvotes: 3

Anton Tykhyy
Anton Tykhyy

Reputation: 20076

lock xadd is your friend.

Upvotes: 11

Related Questions