title: What does the "lock" instruction mean in x86 assembly?
body: <p>I saw some x86 assembly in Qt's source:</p>
  
  <pre><code>q_atomic_increment:
      movl 4(%esp), %ecx
      lock 
      incl (%ecx)
      mov $0,%eax
      setne %al
      ret
  
      .align 4,0x90
      .type q_atomic_increment,@function
      .size   q_atomic_increment,.-q_atomic_increment
  </code></pre>
  
  <ol>
  <li><p>From Googling, I knew <code>lock</code> instruction will cause CPU to lock the bus, but I don't know when CPU frees the bus?</p></li>
  <li><p>About the whole above code, I don't understand how this code implements the <code>Add</code>?</p></li>
  </ol>