Operating System - HP-UX
1835636 Members
3496 Online
110081 Solutions
New Discussion

How many threads belong to this process?

 
Todd Larchuk
Advisor

How many threads belong to this process?

Is there a an HP UX 11 command to tell me how many threads a process is running?

I usually use GlancePlus for this, but it isn't installed on all the machines I need to check.

Thanks.
4 REPLIES 4
SHABU KHAN
Trusted Contributor

Re: How many threads belong to this process?

Todd,

I am not sure if I understood your question correctly..

To look at all the threads for a particular process, you could do a

ps -ef | grep

On Sun's you could use:

ptree

If the threads that you are talking about are java threads then ... do:

ps -ef|grep java|grep

Hope this helps !

-Thanks,
Shabu
MANOJ SRIVASTAVA
Honored Contributor

Re: How many threads belong to this process?

Hi Todd

May be you want to look at lsof .
http://ftp.cerias.purdue.edu/pub/tools/unix/sysutils/lsof/


Manoj Srivastava
Todd Larchuk
Advisor

Re: How many threads belong to this process?

Shabu: When a process has multiple threads they all share the same PID. Internal to the kernel the threads are assigned TID's. That's what GlancePlus can report, but simply grep'ing on PIDs doesn't show the threads.

Manoj: I looked as lsof but I couldn't make use of it to see how many threads were in a process.

All: I did get the advice to use gdb to attach to the process and then use "info threads". That works OK if it's OK to pause the process for awhile. In my present case this was enough.
But, how does GlancePlus know the thread id's? I know it is using the MI daemon to read the kernel structures, but I seem to recall some way to querry the kernel structures directly?


--- thanks for your help.
SHABU KHAN
Trusted Contributor

Re: How many threads belong to this process?

Todd,

Sorry I misunderstood your question, threads can also mean processes ...

If you are talking about multi-threaded, single-threaded environments, then usually the process that starts these threads logs information in its application logs, the logs can sometime indicate how many threads it has started ...

As you mentioned there must be a way to query the kernel on how many threads that particular process is running ...

Good Luck..

Thanks,
Shabu