Mutex Locking/Unlocking In order to actually use the mutex, we need to lock it, perform our 'critical section', and unlock the mutex: ... /* lock the mutex */ if (pthread_mutex_lock(&mutex) != 0) { perror("oh-oh... pthread_mutex_lock:"); exit(1); } /* perform our critical section */ ... /* unlock the mutex. DON'T forget this. */ if (pthread_mutex_unlock(&mutex) != 0) { perror("oh-oh... pthread_mutex_unlock failed:"); exit(1); } The error-handling shown here is simplified - what we do depends on the program we are part of. If we're a function - we'd better return an error, rather then terminate the process we run in.