HP-UX Reference (11i v2 03/08) - 2 System Calls (vol 5)
p
pstat(2) pstat(2)
[EOVERFLOW] For the
pstat_getpathname()
call, the elemcount parameter is not one
greater than the length of the pathname to be returned.
[ENOSTR]
pstat_getstream()
is called for a file which is neither a stream nor a
stream based pipe/socket.
[EINTR] For
pstat_getsocket()
call, the operation was terminated due to the
receipt of a signal, and no data was transferred.
[ENOBUFS] For
pstat_getsocket()
call, the operation was terminated due to unavaila-
bility of buffer space.
[ENOSYS] The requested pstat function is not implemented or not configured in the system.
BACKWARD COMPATIBILITY
The specific calling convention of passing the expected data structure size is used in order to allow for
future expansion of the interface, while preserving backwards source and object compatibility for pro-
grams written using the pstat interfaces. Three rules are followed to allow existing applications to con-
tinue to execute from release to release of the operating system.
• New data for a context are added to the end of that context’s data structure.
• Old, obsolete data members are
NOT
deleted from the data structure.
• The operating system honors the
elemsize parameter of the call and only returns the first
elemsize bytes of the context data, even if the actual data structure has since been enlarged.
In this way, an application which passes its compile-time size of the context’s data structure (for example,
sizeof(struct pst_processor
) for the per-process context) as the elemsize parameter will con-
tinue to execute on future operating system releases without recompilation, even those that have larger
context data structures. If the program is recompiled, it will also continue to execute on that and future
releases. Note that the reverse is not true: a program using the
pstat interfaces compiled on, say, HP-
UX release 10.0 will not work on HP-UX release 9.0.
The code examples, below, demonstrate the calling conventions described above.
EXAMPLES
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/unistd.h>
/*
* Example 1: get global information from pstat_getstatic()
*/
{
struct pst_static pst;
if (pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) != -1)
(void)printf("page size is %d bytes\n", pst.page_size);
else
perror("pstat_getstatic");
}
/*
* Example 2: get information about all processors, first obtaining
* number of processor context instances
*/
{
struct pst_dynamic psd;
struct pst_processor *psp;
if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) != -1) {
size_t nspu = psd.psd_proc_cnt;
psp = (struct pst_processor *)
malloc(nspu * sizeof(struct pst_processor));
if (pstat_getprocessor(psp, sizeof(struct pst_processor), nspu,
0) != -1) {
int i;
HP-UX 11i Version 2: August 2003 − 11 − Hewlett-Packard Company Section 2−−245