On a multicore x86 machine, Say a thread executing on core1 increments an integer variable a
at the same time thread on core 2 also increments it. Given that the initial value of a
was 0, would it always be 2
in the end? Or it could have some other value? Assume that a
is declared as volatile
and we are not using atomic variables (such as atomic<> of C++ and built in atomic operations in gcc).
If the value of a
would indeed be always 2 in such event, does that mean that a long int
in x86-64 would also have the same property, that is, a
will always be 2 in the end?