title: How to synchronize on ARM when one thread is writing code which the other thread may be executing concurrently?
body: <p>Consider a multi-core ARM processor. One thread is modifying a machine code block which is maybe being executed concurrently by another thread. The modifying thread does the following kinds of changes:</p>
  
  <ol>
  <li>Mark the machine code block for skipping: it places a jump instruction as the first instruction of the code block, so that whoever executes it should skip the rest of instructions, jumping over the whole code block.</li>
  <li>Mark the machine code block for execution: it writes the rest of instructions starting from the second, then it atomically replaces the first instruction (the jump) with the intended first instruction of the code block.</li>
  </ol>
  
  <p>For the code writer thread I understand that it is enough to make the final write with <code>std::memory_order_release</code> in C++11.</p>
  
  <p>However it is not clear what to do on the executor thread side (it's out of control, we just control the machine code block we write). Shall we write some instruction barrier before the first instruction of the code block being modified?</p>