Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the no. of active threads in a C program

Status
Not open for further replies.

oraclepg

Programmer
Apr 16, 2002
3
0
0
US
Can somebody let me know how to find the no. of currently active threads in a C program ( Unix environment).
I used Pthread library to create threads.

Thanks
 
/usr/local/bin/top


PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
13072 joe 1 22 0 12M 5784K cpu/0 0:13 12.73% proc1
13141 joe 1 43 0 3104K 2384K cpu/1 0:00 1.07% top
12692 joe 1 58 0 31M 25M sleep 0:21 0.23% proc4
10247 root 6 0 0 7352K 6064K sleep 749:01 0.22% automountd
217 root 30 55 0 31M 23M sleep 87:58 0.18% nscd


the THR column is the THREAD count. now how many of those are ACTIVE and doing work? who knows but if it is a lot of them then it will be at the TOP of the display because it would be using a lot of CPU.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top