dg_cpu_set_affinity(3T) SDK R4.11 dg_cpu_set_affinity(3T)
NAME
dgcpusetaffinity, dgcpugetaffinity - change CPU affinity
attributes of one or more LWP groups
SYNOPSIS
#include <sys/dgcpu.h>
int dgcpusetaffinity(long version,
long selector,
long selectorvalue1,
long selectorvalue2,
dgcpuaffinityattrt *attrptr);
int dgcpugetaffinity(long version,
long selector,
long selectorvalue1,
long selectorvalue2,
dgcpuaffinityattrt *attrptr);
where:
version An integer version number, which should be set to
DGCPUAFFINITYCURRENTVERSION.
selector An integer indicating how to select the LWP groups
whose affinity attributes are being changed by a call
to dgcpusetaffinity(), or how to select the LWP
group whose affinity attributes are being retrieved
by a call to dgcpugetaffinity().
selectorvalue1 An integer denoting the PID of the target process
containing the LWP groups whose affinity attributes
are being set or retrieved.
selectorvalue2 An integer denoting the LWP group ID of the LWP group
whose affinity attributes are being set or retrieved;
this value is ignored when selector is other than
DGCPUAFFINITYSELECTPIDONELWPGROUP.
attrptr A pointer to a CPU affinity attributes object
DESCRIPTION
The dgcpusetaffinity() function is used to change the CPU affinity
attributes of one or more LWP groups in the target process to those
stored in the affinity attributes object pointed to by attrptr. The
dgcpugetaffinity() function is used to retrieve the CPU affinity
attributes of one LWP group in the target process; the attributes are
stored into the affinity attributes object pointed to by attrptr.
For a detailed discussion of CPU affinity and affinity attributes
objects, refer to <sys/dgcpu.h> and dgcpuaffinityattrinit(3T).
Before calling dgcpusetaffinity() or dgcpugetaffinity(), the
affinity attributes object pointed to by attrptr must be initialized
by a call to dgcpuaffinityattrinit(). When the attributes object
is no longer used, it should be destroyed by a call to
dgcpuaffinityattrdestroy().
The functions dgcpusetaffinity() and dgcpugetaffinity() can
manipulate only one process at a time. The PID of the target process
is given by selectorvalue1.
For dgcpusetaffinity(), the selector parameter determines which
LWP groups are affected. If selector is
DGCPUAFFINITYSELECTPIDALLLWPGROUPS, then the affinity
attributes of all LWP groups in the target process are set to those
contained in the attributes object pointed to by attrptr; in this
case, selectorvalue2 is ignored. If selector is
DGCPUAFFINITYSELECTPIDINITLWPGROUP, then the affinity
attributes of the initial LWP group in the target process are set to
those contained in the attributes object pointed to by attrptr; In
this case, selectorvalue2 is also ignored. If selector is
DGCPUAFFINITYSELECTPIDONELWPGROUP, then the affinity
attributes of the LWP group with LWP group ID given by
selectorvalue2 in the target process are set to those contained in
the attributes object pointed to by attrptr.
For dgcpugetaffinity(), the selector parameter determines the LWP
group whose affinity attributes are to be retrieved and then stored
into the attributes object pointed to by attrptr. If selector is
DGCPUAFFINITYSELECTPIDALLLWPGROUPS, then the affinity
attributes for any LWP group in the target process are retrieved; in
this case, DG/UX currently retrieves the affinity attributes of the
initial LWP group in the target process and selectorvalue2 is
ignored. If selector is DGCPUAFFINITYSELECTPIDINITLWPGROUP,
then the affinity attributes of the initial LWP group in the target
process are retrieved; in this case, selectorvalue2 is also ignored.
If selector is DGCPUAFFINITYSELECTPIDONELWPGROUP, then the
affinity attributes of the LWP group with LWP group ID given by
selectorvalue2 in the target process are retrieved.
The value DGCPUINFOCURRENTVERSION should be passed as the version
to both dgcpusetaffinity() and dgcpugetaffinity().
If dgcpugetaffinity() fails, the contents of the attributes object
pointed to by attrptr are undefined.
DIAGNOSTICS
Return Value
If successful, dgcpusetaffinity() and dgcpugetaffinity() return
0. Otherwise, they return -1 and set errno to indicate the error.
Errors
For each of the following conditions, dgcpusetaffinity() and
dgcpugetaffinity() return -1 and set errno to the corresponding
value:
[EINVAL] An invalid affinity attributes object has been specified.
This occurs when DG/UX has detected that the the affinity
attributes object pointed to by attrptr has not been
initialized by a previous call to
dgcpuaffinityattrinit() or has been corrupted.
[EINVAL] The value given by version does not refer to a supported
version number.
[EINVAL] The value given by selector is not
DGCPUAFFINITYSELECTPIDALLLWPGROUPS,
DGCPUAFFINITYSELECTPIDINITLWPGROUP, or
DGCPUAFFINITYSELECTPIDONELWPGROUP.
[ESRCH] The value given by selectorvalue1 does not denote the PID
of an active process.
[ESRCH] When selector is DGCPUAFFINITYSELECTPIDONELWPGROUP,
the value given by selectorvalue2 does not denote the LWP
group ID of an active LWP group in the target process
For each of the following conditions, dgcpusetaffinity() returns
-1 and sets errno to the corresponding value:
[EINVAL] The allowed CPU ID set contained in the affinity attributes
object pointed to by attrptr does not contain at least one
CPU that is currently online.
[EPERM] The caller does not have permission to change the affinity
attributes for the target process.
SEE ALSO
dgcpuaffinityattrinit(3T), dgcpuaffinityattrdestroy(3T),
dgcpuaffinityattrsetcpuidset(3T),
dgcpuaffinityattrgetcpuidset(3T),
dgcpuaffinityattrsetminimumlevel(3T),
dgcpuaffinityattrgetminimumlevel(3T), dgcpuinfo(3T),
dgcpuidsetinit(3T), dgpthreadgroupcreate(3T).
dgpthreadgroupgetlwpgroupid(3T), dglwpinfo(2), threads(5).
NOTE
An application must link with -lthread in order to gain access to
these functions. However, the application need not use threads.
In the current DG/UX implementation, a thread group is the user-level
name for an LWP group. Refer to dgpthreadgroupcreate(3T) for a
discussion on creating thread groups. Thread group IDs can be
translated to LWP group IDs using
dgpthreadgroupgetlwpgroupid(3T). Refer to <sys/dgcpu.h> for a
discussion on the scheduling of LWP groups in the context of CPU
affinity.
Licensed material--property of copyright holder(s)