title: Where does the wait queue for threads lies in POSIX pthread mutex lock and unlock?
body: <p>I was going through concurrency section from <a href="http://pages.cs.wisc.edu/~remzi/OSTEP/" rel="nofollow">REMZI</a> and while going through mutex section, and I got confused about this:</p>
  
  <p>To avoid busy waiting, mutex implementations employ <code>park()</code> / <code>unpark()</code> mechanism (on Sun OS) which puts a waiting thread in a queue with its thread ID. Later on during <code>pthread_mutex_unlock()</code> it removes one thread from the queue so that it can be picked by the scheduler. Similarly, an implementation of Futex (mutex implementation on Linux) uses the same mechanism.</p>
  
  <ol>
  <li><p>It is still unclear to me where the queue lies. Is it in the address space of the running process or somewhere inside the kernel?</p></li>
  <li><p>Another doubt I had is regarding condition variables. Do <code>pthread_cond_wait()</code> and <code>pthread_cond_signal()</code> use normal <a href="http://en.wikipedia.org/wiki/Unix_signal" rel="nofollow">signals</a> and wait methods, or do they use some variant of it?</p></li>
  </ol>