Thread State

Hello,

Is it possible to determine the state (Ready/Terminated) of a thread from
within the same process?

I want to be able to determine if the thread has terminated or not, without
actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc filesystem, but
this would be horrendously slow and inefficient.

Thanks,
Robert.

Robert Muil <r.muil@crcmining.com.au> wrote:

Hello,

Is it possible to determine the state (Ready/Terminated) of a thread from
within the same process?

I want to be able to determine if the thread has terminated or not, without
actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc filesystem, but
this would be horrendously slow and inefficient.

Why do you say it would be really bad? It’s an open() and a devctl().
If you are doing this repeatedly, then it’s just the cost of the devctl().

Cheers,
-RK


[If replying via email, you’ll need to click on the URL that’s emailed to you
afterwards to forward the email to me – spam filters and all that]
Robert Krten, PDP minicomputer collector http://www.parse.com/~pdp8/

try pthread_kill(tid, 0) to get a status.

cheers,
Peter
“Robert Muil” <r.muil@crcmining.com.au> schrieb im Newsbeitrag
news:cogmbf$8ac$1@inn.qnx.com

Hello,

Is it possible to determine the state (Ready/Terminated) of a thread from
within the same process?

I want to be able to determine if the thread has terminated or not,
without
actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc filesystem, but
this would be horrendously slow and inefficient.

Thanks,
Robert.

Robert,

Maybe it wouldn’t be so bad - but I require loop time for my program to be
well under 1 millisecond, so I thought that doing a call to /proc each time
would be impossible.

I will do some tests before I assume anything else.

BTW, your latest book is superb - very useful and written well. Thank you.

Robert.

Robert Krten wrote:

Robert Muil <> r.muil@crcmining.com.au> > wrote:
Hello,

Is it possible to determine the state (Ready/Terminated) of a thread
from within the same process?

I want to be able to determine if the thread has terminated or not,
without actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc
filesystem, but this would be horrendously slow and inefficient.

Why do you say it would be really bad? It’s an open() and a devctl().
If you are doing this repeatedly, then it’s just the cost of the
devctl().

Cheers,
-RK

Robert Muil <r.muil@crcmining.com.au> wrote:

Robert,

Maybe it wouldn’t be so bad - but I require loop time for my program to be
well under 1 millisecond, so I thought that doing a call to /proc each time
would be impossible.

I think you’re pretty safe for the < 1ms part; but yes, doing some tests
is always a good thing…

I will do some tests before I assume anything else.

BTW, your latest book is superb - very useful and written well. Thank you.

Thank you very much!

Cheers,
-RK

Robert.

Robert Krten wrote:
Robert Muil <> r.muil@crcmining.com.au> > wrote:
Hello,

Is it possible to determine the state (Ready/Terminated) of a thread
from within the same process?

I want to be able to determine if the thread has terminated or not,
without actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc
filesystem, but this would be horrendously slow and inefficient.

Why do you say it would be really bad? It’s an open() and a devctl().
If you are doing this repeatedly, then it’s just the cost of the
devctl().

Cheers,
-RK


[If replying via email, you’ll need to click on the URL that’s emailed to you
afterwards to forward the email to me – spam filters and all that]
Robert Krten, PDP minicomputer collector http://www.parse.com/~museum/

That’s the ticket!

Thanks alot, that’s exactly what I needed.

Robert.

Peter Weber wrote:

try pthread_kill(tid, 0) to get a status.

cheers,
Peter
“Robert Muil” <> r.muil@crcmining.com.au> > schrieb im Newsbeitrag
news:cogmbf$8ac$> 1@inn.qnx.com> …
Hello,

Is it possible to determine the state (Ready/Terminated) of a thread
from within the same process?

I want to be able to determine if the thread has terminated or not,
without actually joining it (which rules out pthread_tryjoin).

I know that the information can be gleaned from the /proc
filesystem, but this would be horrendously slow and inefficient.

Thanks,
Robert.