pstat_getlocality.2 (2010 09)
p
pstat_getlocality(2) pstat_getlocality(2)
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",
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 );
}
6 Hewlett-Packard Company − 6 − HP-UX 11i Version 3: September 2010