HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)

p
pset_ctl(2) pset_ctl(2)
PSET_SPUTOPSET
Return the ID of the processor set assigned for the processor specified in id. If the processor is
not enabled or is in transition from one processor set to another, -1 is returned with an error.
The pset argument is ignored.
Any user may query the system processor set topology using the
pset_ctl() function.
Use
sysconf() with _SC_PSET_SUPPORT
name to see if the processor set functionality is supported
by the underlying HP-UX operating system version.
EXAMPLE
Get total count and IDs of all processor sets in the system.
#include <sys/pset.h>
/*
* Get list of all processor sets in the system.
*/
psetid_t *all_psets;
int pset_count, idx;
psetid_t pset;
/* Get total count of processor sets in the system */
pset_count = pset_ctl(PSET_GETNUMPSETS, 0, 0);
if (pset_count < 1) {
perror("pset_ctl(PSET_GETNUMPSETS)");
exit(1);
}
all_psets = (psetid_t *) malloc(sizeof(psetid_t)*pset_count);
memset(all_psets, 0, sizeof(psetid_t)*pset_count);
idx = 0;
/* Get first processor set */
pset = pset_ctl(PSET_GETFIRSTPSET, 0, 0);
if (pset < 0) {
perror("pset_ctl(PSET_GETFIRSTPSET)");
exit(2);
}
all_psets[idx++] = pset;
/* Get remaining processor sets */
while (idx < pset_count) {
pset = pset_ctl(PSET_GETNEXTPSET, pset, 0);
if (pset < 0) {
perror("pset_ctl(PSET_GETNEXTPSET)");
exit(3);
} else {
all_psets[idx++] = pset;
}
}
RETURN VALUE
pset_ctl returns a value based on request on successful completion. Otherwise, -1 is returned and
errno is set to indicate the error.
ERRORS
pset_ctl fails if one or more of the following is true:
[EINVAL] The request is invalid.
[EINVAL] The specified processor set pset, or the processor or the locality domain specified by id is
invalid.
[EINVAL] The request is
PSET_GETNEXTPSET and there is no other processor set after pset, or the
request is PSET_GETNEXTSPU and there is no other processor after id in pset, or the request
is PSET_GETNEXTLDOM and there is no other locality domain after id in pset.
HP-UX 11i Version 1: September 2005 2 Hewlett-Packard Company Section 2231