From owner-freebsd-current Tue Oct 20 10:50:43 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA12465 for freebsd-current-outgoing; Tue, 20 Oct 1998 10:50:43 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from porkfriedrice.ny.genx.net (porkfriedrice.ny.genx.net [206.64.4.30]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA12460 for ; Tue, 20 Oct 1998 10:50:42 -0700 (PDT) (envelope-from bright@hotjobs.com) Received: from localhost (bright@localhost) by porkfriedrice.ny.genx.net (8.9.1/8.9.1) with ESMTP id NAA29023; Tue, 20 Oct 1998 13:52:22 -0400 (EDT) (envelope-from bright@hotjobs.com) X-Authentication-Warning: porkfriedrice.ny.genx.net: bright owned process doing -bs Date: Tue, 20 Oct 1998 13:52:22 -0400 (EDT) From: Alfred Perlstein X-Sender: bright@porkfriedrice.ny.genx.net To: HighWind Software Information cc: current@FreeBSD.ORG Subject: Re: Another Serious libc_r problem In-Reply-To: <199810201618.MAA26576@highwind.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG urk, problem: pthread_cond_broadcast() locks, unqueues, unlocks, schedules then loops. this can cause incorrect behavior when: a thread initiates a broadcast and is prempted after unlocking but before emptying the queue, then during the loop to unqueue and schedule another thread waits on the conditional the thread that joins after the broadcast will be signaled, the broadcast should be atomic. a solution is to store the number of items in a queue. then the broadcast function can malloc that number of pthread_t objects and dequeue them into an array then release the lock and loop while scheduling. but this also causes problems if the sheduling is pre-empted and a thread is scheduled twice. i'll see what i can do about this, i think the real real solution is for the scheduler to be able to atomically dequeue a number of threads in a critical section of code. i apologize for my zealousness that lead to the not correct patch, i also apologize for thinking aloud on this list, but i'm hoping to bring up some valid points for those with more experiance to make sure all the bases are covered. sorry, Alfred Perlstein - Programmer, HotJobs Inc. - www.hotjobs.com -- There are operating systems, and then there's FreeBSD. -- http://www.freebsd.org/ 3.0-current On Tue, 20 Oct 1998, HighWind Software Information wrote: > > Hmmm. Now we got 3 patches. > > I am a little wary about Alfred's "broadcast" patch. Seems premature > optimization. I'd rather have something that is conservative first. > > Can someone with commit priviledges take a peek at this and add one > of these to the source? > > -Rob > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-current" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message