What is a memory fence?
What is meant by using an explicit memory fence? Gwaredd For performance gains modern CPUs often execute instructions out of order to make maximum use of the available silicon (including memory read/writes). Because the hardware enforces instructions integrity you never notice this in a single thread of execution. However for multiple threads or environments with volatile memory (memory mapped I/O for example) this can lead to unpredictable behavior. A memory fence/barrier is a class of instructions that mean memory read/writes occur in the order you expect. For example a 'full fence' means