Use pthread_mutex for buffer locks.