[clug] pthread coroutines

Jepri jepri at webone.com.au
Wed Jul 2 23:24:17 EST 2003

Waitaminit - I just read that with my thinking cap on...

If you only want one out of two threads running all the time, there is 
a common, simlpe portable solution...

use a single threaded application.

I assumed that you wanted to generalise this to n threads, but from 
your responses it looks like you really only have two threads running, 
and only one at a time.

There are only a few cases where threading really helps, most of the 
rest are situations where a non-blocking calls and forking would serve 
just as well.

On 2003.07.02 18:04, Simon Burton wrote:
> Hi,
> How to use mutexes so that effectively only one out of two threads
> is running at a time? Like co-routines. Each thread blocks on a
> pthread_mutex_lock() while the other is running. I'm sure it will come
> to me
> eventually. Or is there Another Way?
> Simon.
> --
> Simon Burton, B.Sc.
> Licensed PO Box A66
> ANU Canberra 2601
> Australia
> Ph. 02 6249 6940       \
> ------------------------\
> ------------------------/
> http://arrowtheory.com /

More information about the linux mailing list