Who ordered memory fences on an x86?

4    28 Jul 2015 21:16 by u/skeeto

1 comment

0

Of course knowing this sort of thing is good for gaining a deeper understanding, but trying to code towards an x86 memory model in anything but assembly will fail for two reasons:

  1. You might suddenly have to target another architecture (ARM for example), and more importantly,
  2. Your compiler will have its own 'memory model' that you can't preempt. For example, you might know that a given write will not be executed out-of-order with a given read on an x86 CPU; but the compiler is still free to elide a non-protected access to memory if it doesn't change the semantics of the program from a single threaded point of view. So it's more important to learn the compiler's 'view' of memory models anyway.