HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
p
pstat(2) pstat(2)
(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);
}
else
perror("pstat_getdynamic");
}
Example 4A
Get information about all processes, 10 at a time. We do it this way since the current count of active
processes is unknown.
main()
{
#define BURST ((size_t)10)
struct pst_status pst[BURST];
int i, count;
int idx = 0; /* pstat index within the Process pstat context */
/* loop until count == 0, will occur all have been returned */
(void)memset(pst,0,BURST*sizeof(struct pst_status));
while ((count=pstat_getproc(pst, sizeof(pst[0]),BURST,idx))>0) {
/* got count this time. process them */
308 Hewlett-Packard Company − 18 − HP-UX 11i Version 3: February 2007