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
|