LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to View Threads per Process (https://www.linuxquestions.org/questions/linux-software-2/how-to-view-threads-per-process-77930/)

Shashi 08-01-2003 01:37 AM

How to View Threads per Process
 
The below code gives u the thrd count given a PID on HP-UX. The same is possible through the pstat kernel interface that HP_UX provides through the pstat_getproc call. The pstat interface is not available on linux, Is there any way to get at that info.

Tried also "ps -m" option but not implemented.

Shashi

>>>>Start
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/unistd.h>
#include <stdio.h>

main()
{
int pid;
struct pst_status pst;
printf("Enter pid number ... ");
scanf("%d",&pid);


if (pstat_getproc(&pst, sizeof(pst), (size_t)0, pid)!= -1)
printf("pid is %d, cmd is %s, # threads %d\n",pst.pst_pid,pst.pst_cmd,pst.pst_nlwps);
else
perror("pstat_getproc");
}

<<<<<<<<End


All times are GMT -5. The time now is 02:53 PM.