title: Basic deadlock issue, one mutex in multiple functions
body: <p>I'm writing a program in C and which has 3 functions in it, A, B and C. I have a static mutex as global which is locking access to these functions. The functions A, B and C and be called in any order from multithreads so, my code looks as follows:</p>
  
  <pre><code>static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  
  int A() {
      pthread_mutex_lock(&amp;mutex);
      ... do some processing...
      pthread_mutex_unlock(&amp;mutex);
      return anInt;
  }
  
  int B() {
      pthread_mutex_lock(&amp;mutex);
      ... do some processing...
      pthread_mutex_unlock(&amp;mutex);
      return anInt;
  }
  
  int C() {
      pthread_mutex_lock(&amp;mutex);
      ... do some processing...
      pthread_mutex_unlock(&amp;mutex);
      return anInt;
  }
  </code></pre>
  
  <p>What might be causing the deadlock?</p>