From owner-freebsd-hackers Mon Dec 28 15:30:52 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA11510 for freebsd-hackers-outgoing; Mon, 28 Dec 1998 15:30:52 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from cimlogic.com.au (cimlog.lnk.telstra.net [139.130.51.31]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA11502 for ; Mon, 28 Dec 1998 15:30:49 -0800 (PST) (envelope-from jb@cimlogic.com.au) Received: (from jb@localhost) by cimlogic.com.au (8.9.1/8.9.1) id KAA16961; Tue, 29 Dec 1998 10:33:01 +1100 (EST) (envelope-from jb) From: John Birrell Message-Id: <199812282333.KAA16961@cimlogic.com.au> Subject: Re: pthreads question/problem... In-Reply-To: <368806B0.721938BF@freedomnet.com> from Kelly Yancey at "Dec 28, 98 05:31:12 pm" To: kbyanc@freedomnet.com (Kelly Yancey) Date: Tue, 29 Dec 1998 10:33:01 +1100 (EST) Cc: freebsd-hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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