2 .\" Copyright (c) 2010 Xin LI <delphij@FreeBSD.org>
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .Dt PTHREAD_ATTR_AFFINITY_NP 3
29 .Nm pthread_attr_getaffinity_np ,
30 .Nm pthread_attr_setaffinity_np
31 .Nd manage CPU affinity in thread attribute objects
37 .Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
39 .Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
42 .Fn pthread_attr_getaffinity_np
44 .Fn pthread_attr_setaffinity_np
45 functions allow the manipulation of sets of CPUs available to the specified thread attribute object.
49 are composed using the
52 If the user-supplied mask is not large enough to fit all of the matching CPUs,
53 .Fn pthread_attr_getaffinity_np
57 .Fn pthread_attr_setaffinity_np
58 tolerate masks of any size with no restrictions.
59 .Fn pthread_attr_setaffinity_np
60 uses the meaningful part of the mask, where the upper bound is
61 the maximum CPU id present in the system.
62 If bits for non-existing CPUs are set, calls to
63 .Fn pthread_attr_setaffinity_np
67 The supplied mask should have a size of
70 This size is usually provided by calling
72 which is ultimately determined by the value of
77 .Fn pthread_attr_getaffinity_np
79 mask from the thread attribute object specified by
81 and stores it in the space provided by
84 .Fn pthread_attr_setaffinity_np
85 sets the mask for the thread attribute object specified by
91 .Fn pthread_attr_getaffinity_np
93 .Fn pthread_attr_setaffinity_np
94 functions will return zero.
95 Otherwise an error number will be returned
96 to indicate the error.
99 .Fn pthread_attr_getaffinity_np
100 functions will fail if:
105 or the attribute specified by it is
114 .Fn pthread_attr_setaffinity_np
115 function will fail if:
120 or the attribute specified by it is
125 specified a CPU that was outside the set supported by the kernel.
127 Insufficient memory exists to store the cpuset mask.
134 .Xr pthread_getaffinity_np 3 ,
136 .Xr pthread_setaffinity_np 3
139 .Nm pthread_attr_getaffinity_np
141 .Nm pthread_attr_setaffinity_np
142 functions are non-standard
144 extensions and may be not available on other operating systems.
147 .Nm pthread_attr_getaffinity_np
149 .Nm pthread_attr_setaffinity_np
150 functions first appeared in
155 .Nm pthread_attr_getaffinity_np
157 .Nm pthread_attr_setaffinity_np
158 functions were written by
159 .An David Xu Aq Mt davidxu@FreeBSD.org ,
160 and this manpage was written by
161 .An Xin LI Aq Mt delphij@FreeBSD.org .