on hpunix cpu usage fields

i have found a structure contained in file global _pstat_body.h at the path
/usr/include/sys/pstat which is
named __pst_dynamic . A field by name psd_cpu_time is
an array of maximum cpu states the kernel supports .
i,e psd_cpu_time [PST_MAX_CPUSTATES] specify all
the cpu timings in an array . i wanted to know which
index into the array spesify which element state i,e
whether the psd_cpu_time[0] is cpu time in user mode
and psd_cpu_time[1] is cpu time in kernel mode and so on .
:confused:

Look at the first few lines in /usr/include/sys/sysinfo.h

thanks for your reply perderabo

    you have shown me a new structure ,

as i saw the fields of structure ksysinfo but i could't find
the system call which fills that structure .will you please help me with that .
vish_shan

See this thread.

hello mr perderabo
thanks for showing me the new tool .
my program written was reffered from your program ,
The call nlist is returning error . please see to my
code and please specify the reason and the
alternative if any .

 --------------------------------------------------------------------------------\#include <sys/param.h>

#include <sys/unistd.h>
#include <nlist.h>
#include <sys/sysinfo.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/vmmeter.h>
main()
{
int fp;
static struct nlist nl[2] = { {"ksysinfo"}, {NULL} };
struct ksysinfo ksysinfo;
int off;
int check ;
fp=open("/dev/kmem", O_RDONLY);
check = nlist("/stand/vmunix",nl);
printf("check = %d\n",check );
off=nl[0].n_value;
lseek(fp,off,SEEK_SET);
read(fp,&ksysinfo,sizeof(struct ksysinfo));

    printf\("%ld\\n",ksysinfo.cpu[0]\);
    printf\("%ld\\n",ksysinfo.cpu[1]\);
    printf\("%ld\\n",ksysinfo.cpu[2]\);
    printf\("%ld\\n",ksysinfo.cpu[3]\);
    printf\("%ld\\n",ksysinfo.cpu[4]\);

}
--------------------------------------------------------------------------------

I tried your code and it worked for me. If nlist returns a zero that is good. Are you getting -1? Are you running as root? You really need to check the result from the open as well.

But the values in that structure were all zeroes. I don't think it is being used. This is the touble with poking around in the kernel. HP changes stuff in there at will. If you get want the cpu times, I would use pstat(). If you must extract them via these calls, I think, that the stuff in sys/dk.h is a better choice.

no ,nlist is returning -1 and i am not running as root . thanks for your reply .

Are you running as root? You need access to /dev/kmem.

no i am not running as root ,and the open call is sucessfull
as fp value is 3 as i checked . so i think the problem is with
nlist .