Date:      Wed, 1 Mar 2000 06:57:54 -0500 (EST)
From:      Daniel Eischen <eischen@vigrid.com>
To:        John Polstra <jdp@polstra.com>
Cc:        current@freebsd.org
Subject:   Re: pthread_{suspend,resume}_np broken?
Message-ID:  <Pine.SUN.3.91.1000301064035.7639A-100000@pcnet1.pcnet.com>
In-Reply-To: <200003010447.UAA74251@vashon.polstra.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 29 Feb 2000, John Polstra wrote: > In article <Pine.SUN.3.91.1000229224700.20669A@pcnet1.pcnet.com>, > Daniel Eischen <eischen@vigrid.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.1000301064035.7639A-100000>
