Question

i have alot of spin locks in my multithread code and most of the time they are waiting for other threads to do work and thus chew alot of cpu usage. In linux i normally use pthread_cond_wait and pthread_cond_signal to pause a thread and wake up when signaled. Is there something like this in the boost libraries? Having a quick look i couldnt find any thing.

Visual studio 2005

Was it helpful?

OTHER TIPS

You are looking for a Mutex or a Semaphore. The Boost library does have Mutex and Semaphore support.

A Mutex is a Binary Semaphore, which is simply thought of as a lock, allowing only one thread to go through your critical section.

Counting semaphores can help to simplify some situations where a lock(Mutex) is too restrictive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top