Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Dec 1998 10:33:01 +1100 (EST)
From:      John Birrell  <jb@cimlogic.com.au>
To:        kbyanc@freedomnet.com (Kelly Yancey)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: pthreads question/problem...
Message-ID:  <199812282333.KAA16961@cimlogic.com.au>
In-Reply-To: <368806B0.721938BF@freedomnet.com> from Kelly Yancey at "Dec 28, 98 05:31:12 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Kelly Yancey wrote:
>   The main thread sets the mutex, the worker thread unlocks the
> mutex...or I should say tries to.

Mutexes are intended for locking between threads. They are not an
application scheduling mechanism. You can easily code a queue of
worker threads that are waiting for something to do. Use a mutex to
protect the updates to the list, with each thread adding itself
to the list when it has nothing to do, and the main thread removing
a thread from the list when it gives it something to do.

> Or am I missing some fundamental aspect of multithreaded
> programming?

You are.

-- 
John Birrell - jb@cimlogic.com.au; jb@freebsd.org http://www.cimlogic.com.au/
CIMlogic Pty Ltd, GPO Box 117A, Melbourne Vic 3001, Australia +61 418 353 137

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812282333.KAA16961>