"In this article, the last of a three-part series on POSIX
threads, Daniel takes a good look at how to use condition
variables. Condition variables are POSIX thread structures that
allow you to "wake up" threads when certain conditions are
met. You can think of them as a thread-safe form of
signalling. Daniel wraps up the article by using all that you've
learned so far to implement a multi-threaded work crew
"I ended my previous article by describing a particular dilemma:
how does a thread deal with a situation where it is waiting for a
specific condition to become true? It could repeatedly lock and
unlock a mutex, each time checking a shared data structure for a
certain value. But this is a waste of time and resources, and this
form of busy polling is extremely inefficient. The best way to do
this is to use the pthread_cond_wait() call to wait on a particular
condition to become true."
"It's important to understand what pthread_cond_wait() does --
it's the heart of the POSIX threads signalling system, and also the
hardest part to understand."
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.