IBM developerWorks: POSIX threads explained, Part 3 - Improve efficiency with condition variables | Linux Today

IBM developerWorks: POSIX threads explained, Part 3 – Improve efficiency with condition variables

Written By
Web Webster
Web Webster
Sep 17, 2000

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
application.”

“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.”


Complete Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.