HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
p
pstat(2) pstat(2)
context data structures. If the program is recompiled, it will also continue to execute on that and future
releases. Note that the reverse is not true: a program using the pstat interfaces compiled on, say, HP-UX
release 10.0 will not work on HP-UX release 9.0.
The code examples, below, demonstrate the calling conventions described above.
EXAMPLES
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/unistd.h>
/*
* Example 1: get static global information
*/
{
struct pst_static pst;
if (pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) != -1)
(void)printf("page size is %d bytes\n", pst.page_size);
else
perror("pstat_getstatic");
}
/*
* Example 2: get information about all processors, first obtaining
* number of processor context instances
*/
{
struct pst_dynamic psd;
struct pst_processor *psp;
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));
if (pstat_getprocessor(psp, sizeof(struct pst_processor), nspu,
0) != -1) {
int i;
int total_execs = 0;
for (i = 0; i < nspu; i++) {
int execs = psp[i].psp_sysexec;
total_execs += execs;
(void)printf("%d exec()s on processor #%d\n",
execs, i);
}
(void)printf("total execs for the system were %d\n",
total_execs);
}
else
perror("pstat_getdynamic");
}
else
perror("pstat_getdynamic");
}
/*
* Example 3: get information about all per-process -- 10 at a time
* done this way since current count of active processes unknown
*/
{
#define BURST ((size_t)10)
struct pst_status pst[BURST];
int i, count;
HP-UX Release 11i: December 2000 − 10 − Section 2−−227
___
___