pstat.2 (2010 09)

p
pstat(2) pstat(2)
struct pst_dynamic psd;
struct pst_processor *psp;
(void)memset(&psd,0,sizeof(struct pst_dynamic));
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == 1) {
size_t nspu = psd.psd_proc_cnt;
psp = (struct pst_processor *)
malloc(nspu * sizeof(struct pst_processor));
(void)memset(psp,0,nspu*sizeof(struct pst_processor));
if (pstat_getprocessor(psp, sizeof(struct pst_processor), nspu,
0) != -1) {
int i;
unsigned long long total_execs = 0;
for (i = 0; i < nspu; i++) {
unsigned long long execs = psp[i].psp_sysexec;
total_execs += execs;
(void)printf("%llu exec()s on processor #%d\n",
execs, i);
}
(void)printf("total execs for the system were %llu\n",
total_execs);
}
else
perror("pstat_getprocessor");
}
else
perror("pstat_getdynamic");
}
Example 3A
Get dynamic information about the amount of virtual memory actively in use on the system.
main()
{
struct pst_dynamic psd;
(void)memset(&psd,0,sizeof(struct pst_dynamic));
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == 1) {
(void)printf("total active virtual memory for the system %lld\n",
psd.psd_avm);
}
else
perror("pstat_getdynamic");
}
Example 3B
Get dynamic information about the amount of virtual memory actively in use on the system. Program
explicitly handles the possibility of [EOVERFLOW] as it is using data from a call that may, in principle,
overflow.
main()
{
struct pst_dynamic psd;
int ret,valid_avm_data;
(void)memset(&psd,0,sizeof(struct pst_dynamic));
ret = pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0);
valid_avm_data = (ret == 1) ||
((ret == -1) && (errno == EOVERFLOW) && (psd.psd_valid & PSD_AVM));
if (valid_avm_data) {
(void)printf("total active virtual memory for the system %lld\n",
psd.psd_avm);
18 Hewlett-Packard Company 18 HP-UX 11i Version 3: September 2010