Use recursive pthread mutexes if available.