title: What is the purpose of the "PAUSE" instruction in x86?
body: <p>I am trying to create a dumb version of a spin lock. Browsing the web, I came across a assembly instruction called "PAUSE" in x86 which is used to give hint to a processor that a spin-lock is currently running on this CPU. The intel manual and other information available state that </p>
  
  <blockquote>
    <p>The processor uses this hint to avoid the memory order violation in
    most situations, which greatly improves processor performance. For
    this reason, it is recommended that a PAUSE instruction be placed in
    all spin-wait loops. The documentation also mentions that  "wait(some
    delay)" is the pseudo implementation of the instruction.</p>
  </blockquote>
  
  <p>The last line of the above paragraph is intuitive. If I am unsuccessful in grabbing the lock, I must wait for some time before grabbing the lock again.</p>
  
  <p>However, what do we mean by memory order violation in case of a spin lock? 
  Does "memory order violation" mean the incorrect <em>speculative</em> load/store of the instructions after spin-lock?</p>
  
  <p>The spin-lock question has been asked on Stack overflow before but the memory order violation question remains unanswered (at-least for my understanding).</p>