HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)

p
pstat_getlocality(2) pstat_getlocality(2)
* 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",
pid );
printf ( "%6s%10s%10s%10s%10s\n",
"idx", "total", "shared", "private", "weighted" );
while ( count ==1){
total += ppl.ppl_rss_total;
shared += ppl.ppl_rss_shared;
private += ppl.ppl_rss_private;
weighted += ppl.ppl_rss_weighted;
pages_to_str ( ppl.ppl_rss_total, total_str );
pages_to_str ( ppl.ppl_rss_shared, shared_str );
pages_to_str ( ppl.ppl_rss_private, private_str );
pages_to_str ( ppl.ppl_rss_weighted, weighted_str );
printf ( "%6d%10s%10s%10s%10s\n",
i, total_str, shared_str,
private_str, weighted_str );
i++;
count = pstat_getproclocality ( &ppl,
sizeof(struct pst_proc_locality),
pid, i );
}
if ( count<0){
if ( errno == ESRCH ) {
fprintf ( stderr, "Process %d not found\n", pid );
exit(1);
}
perror ( "pstat_getproclocality" );
exit(1);
}
if(i==1){
/* Don’t print totals if there’s one locality */
printf ( "\n" );
return;
}
pages_to_str ( total, total_str );
pages_to_str ( shared, shared_str );
pages_to_str ( private, private_str );
pages_to_str ( weighted, weighted_str );
printf ( "%6s%10s%10s%10s%10s\n",
"", "-----", "-----", "-----", "-----" );
printf ( "%6s%10s%10s%10s%10s\n\n",
"", total_str, shared_str,
private_str, weighted_str );
}
/*
* Given a quantity of memory in pages, fill str with a
* human-readable string representing that amount.
*/
HP-UX 11i Version 2: September 2004 6 Hewlett-Packard Company Section 2263