title: Atomic Instruction
body: <p>What do you mean by Atomic instructions?</p>
  
  <p>How does the following become Atomic?</p>
  
  <p>TestAndSet</p>
  
  <pre><code>int TestAndSet(int *x){
     register int temp = *x;
     *x = 1;
     return temp;
  }
  </code></pre>
  
  <p>From a software perspective, if one does not want to use non-blocking synchronization primitives, how can one ensure Atomicity of instruction? is it possible only at Hardware or some assembly level directive optimization can be used?</p>