Hmm, since we are not using any synchronous primitives, do we need a memory fence here to ensure that we print 1 instead of some undefined x?
Only when T0 changes flag to 1 will T1 print x, which is 1.
Modern processors are allowed to rearrange stores and loads that do not have dependencies unless a specific fence is in place though:
http://en.wikipedia.org/wiki/Memory_barrier
Hmm, since we are not using any synchronous primitives, do we need a memory fence here to ensure that we print 1 instead of some undefined x?
Only when T0 changes flag to 1 will T1 print x, which is 1.
Modern processors are allowed to rearrange stores and loads that do not have dependencies unless a specific fence is in place though:
http://en.wikipedia.org/wiki/Memory_barrier