Forum Moderators: bakedjake

Message Too Old, No Replies

Viewing Threads per Process - HPUX

utility for viewing Threads per Process on HPUX - Manish Raje

         

man35

10:03 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Hi

Which utility in HPUX will allow me to view Threads per Process for HP?
/usr/bin/top does not show No of Lightweight Processes (NLWP) information.
Equivalent utility for Solaris is - /usr/bin/prstat.
Also, ps(1) for HPUX hasn't got a -L option support (as Solaris) to view NLWP information.

Thanks,
Manish.

man35

1:34 pm on Jul 18, 2003 (gmt 0)

10+ Year Member



Got this program while searching on net.
Worked for me -

#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);

/*
* First get the desired process to get its 'index'.
* This will be used when retrieving the file data.
*/

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");
}
}

Enter the pid and you get number of threads per process.

-Manish.