Mechanism for thread death notification?

Is there a simple way for a thread to be notified of the death of another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH on
the channel to receive a pulse on the death of a thread.

Join on that thread id?

Richard Doucet wrote:

Is there a simple way for a thread to be notified of the death of another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH on
the channel to receive a pulse on the death of a thread.


cburgess@qnx.com

Colin Burgess <cburgess@qnx.com> wrote:

Join on that thread id?

Cause pthread_join() is blocking, it’s probably even less simple than
the notification.

Richard Doucet wrote:
Is there a simple way for a thread to be notified of the death of another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH on
the channel to receive a pulse on the death of a thread.

Yup, that’s about the best one there is – asynchronous notification of
death with a pulse.

(Though, looking at it, how much simpler did you want?)

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

Richard Doucet wrote:

Is there a simple way for a thread to be notified of the death of another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH on
the channel to receive a pulse on the death of a thread.

You could use a thread-specific data destructor or a cleanup handler to
send you whatever kind of notification is most convenient for you.
Unless the reason you want this is debugging, it’s probably a good thing
that this lets you decide which threads it should notify you about…

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:d7nras$qjp$1@inn.qnx.com

Colin Burgess <> cburgess@qnx.com> > wrote:
Join on that thread id?

Cause pthread_join() is blocking, it’s probably even less simple than
the notification.

Richard Doucet wrote:
Is there a simple way for a thread to be notified of the death of
another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH
on
the channel to receive a pulse on the death of a thread.

Yup, that’s about the best one there is – asynchronous notification of
death with a pulse.

(Though, looking at it, how much simpler did you want?)

What makes it complex is that this is a Photon application , in which I
don’t direct have access to dispatcher. With a dispatcher, I agree, it’s
somewhat simple.

This is not the first time Photon application complicated our code. Our
communication framework easily ported over from QNX 4, up until we had to
get Photon applications integrated. Then things started to get messy.

The other “beef” I have with RTP is the inablity to have control over the
channel when using a dispatcher to set the proper flags. Yes, we are using
the undocumneted _dispatch_create(); I think QSSL should make this part of
the standard libraries. To get our software qualified to meet standards, we
would be hard press to convince them that it’s ok to use undocumented
features of the OS…

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

Richard Doucet <doucetr@aecl.ca> wrote:

“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:d7nras$qjp$> 1@inn.qnx.com> …
Is there a simple way for a thread to be notified of the death of
another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH
on
the channel to receive a pulse on the death of a thread.

Yup, that’s about the best one there is – asynchronous notification of
death with a pulse.

(Though, looking at it, how much simpler did you want?)

What makes it complex is that this is a Photon application , in which I
don’t direct have access to dispatcher. With a dispatcher, I agree, it’s
somewhat simple.

Ah, yes, doing it in a Photon program is more complicated. I don’t know
how to handle system pulses in a Photon program.

But, the thing I always wonder about in this situation, is how do you
happen to have threads “disappearing”, so that you need to get notified
of it? Is there an external library or something you don’t control that
could cause a thread to just exit in the library? (Though, the thread pool
stuff could cause this.)

Because, you could replace all calls to pthread_exit() with a call to
my_pthread_exit() which delivers the notification you want, then calls
the regular pthread_exit(). Though, you’d also have to make sure no
thread functions return, but instead do a my_pthread_exit() instead.

This is not the first time Photon application complicated our code. Our
communication framework easily ported over from QNX 4, up until we had to
get Photon applications integrated. Then things started to get messy.

Yeah.

The other “beef” I have with RTP is the inablity to have control over the
channel when using a dispatcher to set the proper flags. Yes, we are using
the undocumneted _dispatch_create(); I think QSSL should make this part of
the standard libraries. To get our software qualified to meet standards, we
would be hard press to convince them that it’s ok to use undocumented
features of the OS…

I don’t disagree on this one.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

On Thu, 2 Jun 2005 16:09:31 -0300, Richard Doucet wrote:

Is there a simple way for a thread to be notified of the death of another
thread within a process?

The only thing I could find in the docs is setting _NTO_CHF_THREAD_DEATH on
the channel to receive a pulse on the death of a thread.

What we do is put thread creation inside a wrapper class that actually
creates two threads, one that does the work, and the other just does a
pthread_join() on the worker thread and sits there waiting for the worker
thread to complete. When the worker thread exits, the join thread gets the
exit status of the worker thread and does appropriate clean-up and
notification. Not very elegant, but it works for us.

Rob Rutherford
Ruzz Technology