I'm just here to point out the mistake about volatile in Orion Edwards' answer.
He said:
"If it is volatile, this just ensures the two CPUs see the same data atthe same time."
It's wrong. In microsoft' doc about volatile, mentioned:
"On a multiprocessor system, a volatile read operation does notguarantee to obtain the latest value written to that memory locationby any processor. Similarly, a volatile write operation does notguarantee that the value written would be immediately visible to otherprocessors."