pstat_getlocality.2 (2010 09)
p
pstat_getlocality(2) pstat_getlocality(2)
fprintf ( stderr, "returned in addition to system-wide " );
fprintf ( stderr, "information.\n\n" );
exit(1);
}
/*
* Verify arguments, call sys_locinfo(), and call pid_locinfo()
* if desired.
*/
int
main ( int argc, char **argv )
{
pid_t pid = (pid_t) 0;
if ( (argc == 2) || (argc > 3) ||
((argc == 3) && (strncmp(argv[1], "-p", 2))) ) {
usage(argc, argv);
}
if ( argc == 3 ) {
pid = atoi(argv[2]);
if (pid < 0) {
/* note that pid 0 is "this process" */
usage(argc, argv);
}
}
/* Get the size of a page for later calculations */
pgsize = sysconf ( _SC_PAGE_SIZE );
sys_locinfo();
if ( argc == 3 ) {
pid_locinfo ( pid );
}
return 0;
}
/*
* Display the system-wide memory usage per locality.
*/
void
sys_locinfo ( void )
{
int i; /* index within pstl[] */
int count; /* the actual number of pstl structures */
int idx = 0; /* index within the context of localities */
struct pst_locality pstl[BURST];
char total_str[STRSZ], free_str[STRSZ], used_str[STRSZ];
uint64_t total=0, free=0;
printf ( " --- System wide locality info: --- \n" );
printf ( "%6s%6s%7s%6s%10s%10s%10s\n",
"index", "ldom", "physid", "type",
"total", "free", "used" );
/* Get a maximum of BURST pst_locality structures */
count = pstat_getlocality ( pstl, sizeof(struct pst_locality),
BURST, idx );
while ( count >0){
4 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: September 2010