title: How does a function becomes atomic?
body: <p>I have been reading the book called art of multiprocessor programming and came across functions such as get(), getandset(), compareandset(), getandIncrease(), getandIncrease() etc. </p>
  
  <p>In the book it says that all the above function are atomic and I agree but I had my own doubts on how some function becomes a atomic function.  </p>
  
  <p>Why does the function with <strong><em>get</em></strong> or <strong><em>compare</em></strong> become atomic ? - because it has to wait till it gets the value or waits till some condition becomes true which creates a barrier,  hence atomic. </p>
  
  <p>Am I right in thinking this way? is there any thing that I have missed ?</p>
  
  <p>When I do </p>
  
  <pre><code> if (tail_index.get() == (head_index.getAndIncrement()) 
  </code></pre>
  
  <p>is this atomic?</p>