HP-UX 11i v3 Memory Management Subsystem

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.
*/
void
pages_to_str ( uint64_t pages, char *str )
{
uint64_t kpg = pages*(pgsize/1024L);
uint64_t mpg = kpg/1024L;
uint64_t gpg = mpg/1024L;
if ( gpg > 0 ) {
sprintf ( str, "%.2lfG", (((double)kpg/1024.0)/1024.0));
} else if ( mpg > 0 ) {
sprintf ( str, "%.2lfM", ((double)kpg/1024.0));
} else if ( kpg > 1 ) {
sprintf ( str, "%lluK", kpg );
} else {
sprintf ( str, "%llu", pages );
}
}
© Copyright 2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to
change without notice. The only warranties for HP products and services are set forth in the express warranty
statements accompanying such products and services. Nothing herein should be construed as constituting an
additional warranty. HP shall not be liable for technical or editorial errors or omissions contained herein.
Oracle is a trademark of Oracle Corporation.
UNIX is a trademark of the Open Group.
5900-0908, August 2010