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
)
psid
)
psid
.
psid
, cpu
, opsid
)
cpuid
to the processor set specified by
psid
.
Stores the current processor set ID of the processor or
PS_NONE
into
opsid
,
if the pointer is not
NULL
.
If
psid
is set to
PS_QUERY
,
then the current processor set ID will be returned into
psid
,
and no assignment will be performed.
If
psid
is set to
PS_MYID
,
then the processor set ID of the calling process will be used, and
psid
will be ignored.
If
psid
is set to
PS_NONE
,
any assignment to the processor will be cleared.
psid
, type
, id
, opsid
)
psid
to the target specified by
id
.
The current processor set ID to which the target is bound or
PS_NONE
will be returned in
opsid
,
if the pointer is not
NULL
.
NetBSD
supports the following types of targets specified by
type
:
P_PID
P_LWPID
If
psid
is set to
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.
If
psid
is set to
PS_MYID
,
then the processor set ID of the calling process will be used.
If
psid
is set to
PS_NONE
,
the specified target will be unbound from the processor set.
psid
)
psid
.
Before destroying the processor set, all related assignments of the
processors will be cleared, and all bound threads will be unbound.
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");
)
function fails if:
ENOMEM
]
EPERM
]
The
pset_assign()
function fails if:
EBUSY
]
EINVAL
]
psid
or
cpuid
are invalid.
EPERM
]
psid
is not
PS_QUERY
.
The
pset_bind()
function fails if:
EBUSY
]
EINVAL
]
psid
or
type
are invalid.
EPERM
]
psid
is not
PS_QUERY
.
ESRCH
]
The
pset_destroy()
function fails if:
EBUSY
]
EPERM
]