mutex and condition variable

Hi,
1 I think mutex is enough, why we need condition variable? I know I am something wrong here, please correct me.
2 pthread_mutex_lock().
"The mutex object referenced by mutex shall be locked by calling pthread_mutex_lock(). If the mutex is already locked, the calling thread shall block until the mutex becomes available."
How about the CPU usage for this period? I know there are two methods to notice the waiter: poll and event-driven. which method was used here ? Where can I got this info?
Thanks you very much!

Thanks
Last edited on
A condition variable is used to signal a thread (from another thread). This is different from what a mutex does.
Thanks for your reply.

Without this signal, pthead_mutex_lock also can get the mutex if the mutex is avaiable, right?

With the signal, the performance will be better ?
They're different things. You lock/unlock a mutex. You wait/signal a cond variable.

You can Google for pthreads.

There's an example using mutex/cond variable here:
http://publib.boulder.ibm.com/infocenter/iserieshttp://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Frzahw%2Frzahwe17rx.htm
Last edited on
Topic archived. No new replies allowed.