title: Mutex takes a long while to unlock
body: <p>I have two threads. First one is something like this:</p>
  
  <pre><code>while(1)
  {
     pthread_mutex_lock(&amp;mutex);
     //DO WORK
     pthread_mutex_unlock(&amp;mutex);
     pthread_yield();
  }
  </code></pre>
  
  <p>The second one locks the mutex on user event, change some settings and unlocks. Thread one does ~ 200 iterations a second. However on occasion it takes the second thread up to 3 seconds to get active (to lock the mutex). How do I ensure faster response?</p>
  
  <p>EDIT- second thread:</p>
  
  <pre><code>while(1)
  {
     waitForUserInput(); // blocking call to linux input
     pthread_mutex_lock(&amp;mutex);
     // Change some settings which are used by the first thread
     pthread_mutex_unlock(&amp;mutex);
  }
  </code></pre>
  
  <p>EDIT2 - Fixed the question ("to unlock the mutex" -> "to lock the mutex").</p>