Introduction to Conditional Variables

This lesson presents the motivation to study conditional variables.

Thus far you have developed the notion of a lock and seen how one can be properly built with the right combination of hardware and OS support. Unfortunately, locks are not the only primitives that are needed to build concurrent programs.

In particular, there are many cases where a thread wishes to check whether a condition is true before continuing its execution. For example, a parent thread might wish to check whether a child thread has completed before continuing, this is often called a join(). How should such a wait be implemented? Let’s look at the code excerpt below:

Get hands-on with 1200+ tech skills courses.