HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)
p
pstat_getlocality(2) pstat_getlocality(2)
printf ( "%6d%6lld%7lld%6s%10s%10s%10s\n",
(idx+i),
pstl[i].psl_ldom_id,
pstl[i].psl_physical_id,
((pstl[i].psl_flags & PSL_INTERLEAVED) ?
"ILV":"CLM"),
total_str, free_str, used_str );
}
idx += count;
/*
* Get (at most) the next BURST pst_locality
* structures, starting at idx
*/
count = pstat_getlocality ( pstl,
sizeof(struct pst_locality),
BURST, idx );
}
if ( count <0){
perror ( "pstat_getlocality" );
exit(1);
}
if ( idx == 1 ) {
/* Don’t print totals if there’s one locality */
printf ( "\n" );
return;
}
/* Convert integer totals into strings */
pages_to_str ( total, total_str );
pages_to_str ( free, free_str );
pages_to_str ( total-free, used_str );
/* Print totals */
printf ( "%6s%6s%7s%6s%10s%10s%10s\n",
"", "", "", "", "-----", "-----", "-----" );
printf ( "%6s%6s%7s%6s%10s%10s%10s\n\n",
"", "", "", "", total_str, free_str, used_str );
}
/*
* Given a pid, display its per-locality physical memory usage.
*/
void
pid_locinfo ( pid_t pid )
{
int count, i=0;
struct pst_proc_locality ppl;
char total_str[STRSZ], shared_str[STRSZ];
char private_str[STRSZ], weighted_str[STRSZ];
uint64_t total=0, shared=0, private=0, weighted=0;
/*
* With this interface, information on only one locality
* can be returned at a time. This will get the first:
*/
count = pstat_getproclocality ( &ppl,
sizeof(struct pst_proc_locality), pid, i );
printf ( " --- Per-process locality info for pid %d: ---\n",
HP-UX 11i Version 2: August 2003 − 5 − Hewlett-Packard Company Section 2−−257