[comp.sys.next] notification of thread death

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

In writing multi-threaded applications in Mach on the NeXT
it would be useful to get notification when one of the threads
dies.  Does anybody know how to obtain this information?

I am using the Mach cthreads package with threads that have been
chtread_detach()ed.  (I do not want to have to cthread_join().)
I would like to receive notification of the death of the thread's
kernel port on the task notify port.  However, all my tests show
that when a thread dies no notification is send to the task
notify port of the task in which the thread was running.  In fact,
when a thread dies by means of thread_exit() or simply a return
from the thread's top level function no notification is sent to
any other tasks which have send rights to that thread's kernel
port.  (Incidentally, this might explain why gdb still thinks
that the thread is alive (using 'tl') when a thread exits in this
way.)

I have been able to get a notify message if I terminate
a thread using the following function call:
        thread_terminate(cthread_thread(cthread_self()));
However, the notification message is only sent to notify ports
of other tasks which have send rights to the thread's kernel port.

I also do not want to have to poll using
        task_threads(task_self(), ...)

Any information or suggestions by email would be appreciated.  I
will post a summary if/when significant facts are revealed to me.
-- 
Eric Hammond
erich@kgw2.bwi.wec.com

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

Please see comp.os.mach for continuation of this thread.
-- 
Eric Hammond
erich@kgw2.bwi.wec.com