[comp.os.mach] cthread termination

erich@kgw2.bwi.WEC.COM (Eric Hammond) (02/17/90)

In article <8ZqaNoK00hYPEpsEdz@cs.cmu.edu>
Richard.Draves@CS.CMU.EDU writes:
> In any case, I don't think it is a good idea to kill a thread that the
> cthreads library thinks it is using.
>
> Perhaps you could just have your cthread send its own notification
> messages before it exits?

At the moment I am doing the equivalent of sending notification of
cthread termination just before each cthread exits.  So far this is
working fine; however, I have a couple more questions:

1) Is there any way for a cthread to terminate unexpectedly (i.e.,
   without doing an explicit cthread_exit() or returning from the
   cthread's top level function)?  Tasks may be terminated by memory
   exceptions, signals, etc.; is there anything like this that will
   terminate a single cthread?  (I don't want any cthreads in this task
   to die without the main cthread of the task knowing it.)

2) I understand the problem with thread_terminate()ing a thread out
   from under the cthread library implementation.  Is there any way
   to do a cthread_terminate()?  How can one cthread terminate
   the execution of another cthread in a task?  Is it necessary to
   set up a "please kill yourself" message or to use similar
   inter-cthread cooperation?

Thanks also to Bill Bolosky for responding to the original question.

-- 
Eric Hammond
erich@kgw2.bwi.wec.com

Richard.Draves@CS.CMU.EDU (02/22/90)

Excerpts from netnews.comp.os.mach: 16-Feb-90 cthread termination (was:
n.. Eric Hammond@kgw2.bwi.WE (1351)

> 1) Is there any way for a cthread to terminate unexpectedly (i.e.,
>    without doing an explicit cthread_exit() or returning from the
>    cthread's top level function)?

No, your cthreads will only terminate via cthread_exit(), possibly
implicitly if they return from their top-level function.

> 2) I understand the problem with thread_terminate()ing a thread out
>    from under the cthread library implementation.  Is there any way
>    to do a cthread_terminate()?  How can one cthread terminate
>    the execution of another cthread in a task?  Is it necessary to
>    set up a "please kill yourself" message or to use similar
>    inter-cthread cooperation?

There is no mechanism for gunning down another cthread.  Your cthreads
have to cooperate.

Rich