dimanche 29 juillet 2018

What will happen if two atomic fetch_add execute simultaneously?

As far as I know, atomic operations of atomic type in cpp11 are guaranteed to be aomtic. However, suppose in multi-core system, if two threads do following operation simultaneously, will the result be 1?(suppose initially atomic<int> val=0;)

val.fetch_add(1,std::memory_order_relaxed);

Aucun commentaire:

Enregistrer un commentaire