Previous | Next --- Slide 44 of 48
Back to Lecture Thumbnails
jiajunbl

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?

BigFish

Only when T0 changes flag to 1 will T1 print x, which is 1.

jiajunbl

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