title: spin locks not consuming 100% cpu
body: <pre><code>#include "boost/smart_ptr/detail/spinlock.hpp"
  boost::detail::spinlock lock;
  main(){
      std::lock_guard&lt;boost::detail::spinlock&gt; guard(lock);
      while(true)
          {
                  i=i+100;
          }
  }
  </code></pre>
  
  <h2>Machine details:</h2>
  
  <p>CPU(s):                2</p>
  
  <p>On-line CPU(s) list:   0,1</p>
  
  <p>Thread(s) per core:    1</p>
  
  <p>Core(s) per socket:    2</p>
  
  <p>Socket(s):             1</p>
  
  <p>Of the above code, When i ran :</p>
  
  <p><code>First instance =&gt;</code>  it took 100% of the cpu( as per top command)</p>
  
  <p><code>Second instance =&gt;</code> it took 97-98% and the sum of these two instances show approx 195%-197%</p>
  
  <p><code>Third instance =&gt;</code>  it took ~47-50% and the sum of these three showed close to 200% , by adjusting cpu consumption of first two instances.</p>
  
  <p>My assumption was that, once the spin lock acquires the cpu, it doesn't get prempted by cpu(it doesn't get switched by cpu by scheduling some other thread for this time keeping the thread(spin locked) in scheduling queue), and hence i was expecting third instance to fail.
  But it ran showing that the first two processes thread's were prempted.</p>
  
  <p>Where am i getting it wrong?</p>