On Tue, 29 Feb 2000, John Polstra wrote:

> In article <[EMAIL PROTECTED]>,
> Daniel Eischen  <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to