HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)
p
pstat_getlocality(2) pstat_getlocality(2)
Notes
These functions only return the wide (64 bit) versions of their associated structures. In order for narrow
(32 bit) applications to use these interfaces, the flag
-D_PSTAT64 must be used at compile time. These
interfaces are available for narrow applications written in standard C and extended ANSI, and for all wide
applications.
RETURN VALUE
pstat_getlocality()
and pstat_getproclocality()
return the following values:
n Successful completion. n is the number of instances returned in buf .
-1 Failure.
errno is set to indicate the error.
ERRORS
Upon failure,
errno is set to one of the following values.
[EFAULT] buf points to an invalid address.
[EINVAL] elemsize is less than or equal to zero, or elemsize is larger than the size of the associ-
ated data structure.
[EINVAL] index is negative.
[ESRCH] for pstat_getproclocality(), the requested pid could not be found.
EXAMPLES
/*
* This program returns system-wide and per-process memory
* locality information. To compile the 32-bit version,
* use -D_PSTAT64. The 64-bit version does not need any
* special compiler flags.
*/
#include <unistd.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/errno.h>
#define BURST ((size_t)3)
#define STRSZ 80
unsigned long pgsize;
void pid_locinfo ( pid_t pid );
void sys_locinfo ( void );
void pages_to_str ( uint64_t pages, char *str );
void
usage ( int argc, char **argv )
{
fprintf ( stderr, "Usage: %s [-p pid]\n", argv[0] );
fprintf ( stderr, "This program prints out per locality " );
fprintf ( stderr, "memory usage.\nIf ’pid’ is supplied, " );
fprintf ( stderr, "information on that process is\n" );
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
HP-UX 11i Version 3: February 2007 − 3 − Hewlett-Packard Company 319