From owner-freebsd-current Wed Mar 1 3:58:15 2000 Delivered-To: freebsd-current@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id C2CC437BD7D for ; Wed, 1 Mar 2000 03:58:11 -0800 (PST) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id GAA09200; Wed, 1 Mar 2000 06:57:54 -0500 (EST) Date: Wed, 1 Mar 2000 06:57:54 -0500 (EST) From: Daniel Eischen To: John Polstra Cc: current@freebsd.org Subject: Re: pthread_{suspend,resume}_np broken? In-Reply-To: <200003010447.UAA74251@vashon.polstra.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 On Tue, 29 Feb 2000, John Polstra wrote: > In article , > Daniel Eischen wrote: > > On Tue, 29 Feb 2000, John Polstra wrote: > > > > > Shouldn't the test against PS_SUSPENDED be "==" instead of "!="? > > > > Yes, it should be "==" instead of "!=". > > > > Go ahead and fix it if you want :-) > > Thanks. I'll ask Jordan if I may commit the fix. > > What about the other part of my question? I still don't understand > why in my test program pthread_suspend_np() isn't suspending the > thread. I think it's a separate bug from the pthread_resume_np() bug. Sorry, it was very late here and I missed that part. I see the problem. pthread_suspend_np is broke in that it only will work if the thread is running (PS_RUNNING). Your program is always trying to suspend a thread that is sleeping (PS_SLEEP_WAIT) so changing the state with PTHREAD_NEW_STATE fails. The fix isn't as easy as just correctly setting the threads state. Potentially, the suspended thread could be waiting on a mutex or condition variable and be in another queue. The correct fix is probably to save the threads old state and then set the threads state to PS_SUSPENDED. Resuming should restore the saved thread state. I'll see if I can come up with a correct fix for this. Dan Eischen eischen@vigrid.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message