PSET(3) | Library Functions Manual | PSET(3) |
pset_create
, pset_assign
,
pset_bind
, pset_destroy
—
#include <sys/pset.h>
int
pset_create
(psetid_t
*psid);
int
pset_assign
(psetid_t
psid, cpuid_t
cpuid, psetid_t
*opsid);
int
pset_bind
(psetid_t
psid, idtype_t
type, id_t id,
psetid_t *opsid);
int
pset_destroy
(psetid_t
psid);
pset_create
(psid)pset_assign
(psid,
cpu, opsid)PS_NONE
into
opsid, if the pointer is not
NULL
.
The following actions can be specified:
PS_QUERY
, then the current processor set ID
will be returned into psid, and no assignment
will be performed.PS_MYID
, then the processor set ID of the
calling process will be used, and psid will be
ignored.PS_NONE
, any assignment to the processor will
be cleared.pset_bind
(psid,
type, id,
opsid)PS_NONE
will be
returned in opsid, if the pointer is not
NULL
. NetBSD supports the
following types of targets specified by type:
The following actions can be specified:
PS_QUERY
, then the current processor set ID to
which the target is bound or PS_NONE
will be
returned in opsid, and no binding will be
performed.PS_MYID
, then the processor set ID of the
calling process will be used.PS_NONE
, the specified target will be unbound
from the processor set.pset_destroy
(psid)If psid is
PS_MYID
, the processor set ID of the caller
thread will be used.
pset_bind
() function can return the current
processor set ID to which the target is bound, or
PS_NONE
. However, for example, the process may have
many threads, which could be bound to different processor sets. In such a case
it is unspecified which thread will be used to return the information.
There is an alternative thread affinity interface, see affinity(3). However, processor sets and thread affinity are mutually exclusive, hence mixing of these interfaces is prohibited.
psetid_t psid; cpuid_t ci = 0; if (pset_create(&psid) < 0) err(EXIT_FAILURE, "pset_create"); /* Assign CPU 0 to the processor-set */ if (pset_assign(psid, ci, NULL) < 0) err(EXIT_FAILURE, "pset_assign"); /* Bind the current process to the processor-set */ if (pset_bind(psid, P_PID, P_MYID, NULL) < 0) err(EXIT_FAILURE, "pset_bind"); /* * At this point, CPU 0 runs only the current process. */ perform_work(); if (pset_destroy(psid) < 0) err(EXIT_FAILURE, "pset_destroy");
pset_create
() function fails if:
ENOMEM
]EPERM
]The pset_assign
() function fails if:
EBUSY
]EINVAL
]EPERM
]PS_QUERY
.The pset_bind
() function fails if:
EBUSY
]EINVAL
]EPERM
]PS_QUERY
.ESRCH
]The pset_destroy
() function fails if:
May 6, 2010 | NetBSD 9.0 |