Friday 22 February 2019

assembly - Is a memory barrier an instruction that the CPU executes, or is it just a marker?

I am trying to understand what is a memory barrier exactly.
Based on what I know so far, a memory barrier (for example: mfence) is used to prevent the re-ordering of instructions from before to after and from after to before the memory barrier.



This is an example of a memory barrier in use:



instruction 1
instruction 2

instruction 3
mfence
instruction 4
instruction 5
instruction 6


Now my question is: Is the mfence instruction just a marker telling the CPU in what order to execute the instructions? Or is it an instruction that the CPU actually executes like it executes other instructions (for example: mov).

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...