From owner-freebsd-java Wed Dec 12 4:28:41 2001 Delivered-To: freebsd-java@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 2DF9337B405 for ; Wed, 12 Dec 2001 04:28:36 -0800 (PST) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.12.1/8.12.1) id fBCCOCBr012831; Wed, 12 Dec 2001 07:24:12 -0500 (EST) Date: Wed, 12 Dec 2001 07:24:12 -0500 (EST) From: Daniel Eischen To: Bill Huey Cc: Bill Huey , Nate Williams , absinthe@pobox.com, shanon loveridge , freebsd-java@FreeBSD.ORG Subject: Re: Pthreads bug fix [was Re: jdk1.3.1p5] In-Reply-To: <20011212074342.GB4677@gnuppy> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Tue, 11 Dec 2001, Bill Huey wrote: > On Tue, Dec 11, 2001 at 11:06:55PM -0500, Daniel Eischen wrote: > > So it looks to me like the problem is that the scheduler is > > waking up the thread and making it runnable before it is > > resumed. Is that the case? Does the following look like > > it might solve the problem? > > > > Index: uthread_kern.c > > =================================================================== > > RCS file: /opt/d/CVS/src/lib/libc_r/uthread/uthread_kern.c,v > > retrieving revision 1.38 > > diff -u -r1.38 uthread_kern.c > > --- uthread_kern.c 4 May 2001 20:37:07 -0000 1.38 > > +++ uthread_kern.c 12 Dec 2001 04:15:35 -0000 > > @@ -387,6 +387,10 @@ > > ((pthread->wakeup_time.tv_sec == ts.tv_sec) && > > (pthread->wakeup_time.tv_nsec <= ts.tv_nsec)))) { > > switch (pthread->state) { > > + case PS_SUSPENDED: > > + PTHREAD_WAITQ_REMOVE(pthread); > > + pthread->suspended = SUSP_YES; > > + break; > > case PS_POLL_WAIT: > > case PS_SELECT_WAIT: > > /* Return zero file descriptors ready: */ > > Dan Eischen > > [/me thinks] > > ... > > Hmmm, whether this solves the problem and keeps it marked as PS_SUSPENDED, > I don't really know since I'm pretty much a neophyte at pthreads internals, > but I'm hoping that I articulate the problem clear enough that you can > find a more direct fix for this problem. Yes, this should keep the state equal to PS_SUSPENDED. When the thread is resumed, its state should be set to PS_RUNNING and then it will be added back to the run queue. > The thing that I don't see in that logic is how it can restore the > PS_COND_WAIT state before the suspend attempt. I'd normally think that > "thread->suspended = SUSP_COND_WAIT" would be needed so that it can be > remarked PS_COND_WAIT when a resume operation is requested. I don't see > how it can be put into that state in the other parts of the pthreads library > or if that's a relevant consideration. Suspsended threads are not placed in the waiting queue unless they are _already_ in the waiting queue (e.g. due to waiting on a condition variable). Any thread that is in the waiti queue and times out should become runnable unless it is suspended, in which case it should just be removed from the waiting queue and remain in a suspended state. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message