C

Asked • 03/18/19

Why do pthreads’ condition variable functions require a mutex?

I’m reading up on `pthread.h`; the condition variable related functions (like `pthread_cond_wait(3)`) require a mutex as an argument. Why? As far as I can tell, I’m going to be creating a mutex *just* to use as that argument? What is that mutex supposed to do?

1 Expert Answer

By:

Tridip C. answered • 08/05/20

Tutor
4.9 (332)

5+ years of Experience in Programming in C/C++

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.