title: Minimum and maximum possible value of a shared variable when incremented by multiple threads
body: <p>I have a global shared variable and that is being updated 5 times by each of the 5 threads spawned. As per my understanding the increment operation is consisting of 3 instructions </p>
  
  <pre><code>load  reg, M
  inc reg
  store reg, M
  </code></pre>
  
  <p>So I want to ask that in this scenario what would be the maximum and minimum value given arbitrary interleaving in the 5 threads.</p>
  
  <p>So according to me the maximum value will be 25 ( I am 100% sure that it can be more than 25) and the minimum value is 5. But I am not so sure on minimum value. Can it be less that 5 in some arbitrary interleaving ?
  Any inputs will be greatly appreciated. </p>
  
  <pre><code>/* Global Variable */
  int var = 0;
  
  /* Thread  function */
  void thread_func()
  {
       for(int c = 0; c &lt; 5; c++)
               var++;
  }
  </code></pre>