Pthread Mutex: pthread_mutex_unlock() consumes lots of time
问题 I wrote a multi-thread program with pthread, using the producer-consumer model. When I use Intel VTune profiler to profile my program, I found the producer and consumer spend lots of time on pthread_mutex_unlock. I don't understand why this happened. I think threads may wait a long time before they can acquire a mutex, but releasing a mutex should be fast, right? The snapshot below is from Intel VTune. It shows the codes where consumer tries to fetch an item from the buffer, and time consumed