2 .\" Copyright (c) 2010 Xin LI <delphij@FreeBSD.org>
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\" notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\" notice, this list of conditions and the following disclaimer in the
12 .\" documentation and/or other materials provided with the distribution.
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .Dt PTHREAD_ATTR_AFFINITY_NP 3
32 .Nm pthread_attr_getaffinity_np ,
33 .Nm pthread_attr_setaffinity_np
34 .Nd manage CPU affinity in thread attribute objects
40 .Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
42 .Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
45 .Fn pthread_attr_getaffinity_np
47 .Fn pthread_attr_setaffinity_np
48 functions allow the manipulation of sets of CPUs available to the specified thread attribute object.
52 are composed using the
55 The kernel tolerates large sets as long as all CPUs specified
57 Sets smaller than the kernel uses generate an error on calls to
58 .Fn pthread_attr_getaffinity_np
59 even if the result set would fit within the user supplied set.
61 .Fn pthread_attr_setaffinity_np
62 tolerate small sets with no restrictions.
64 The supplied mask should have a size of
67 This size is usually provided by calling
69 which is ultimately determined by the value of
74 .Fn pthread_attr_getaffinity_np
76 mask from the thread attribute object specified by
78 and stores it in the space provided by
81 .Fn pthread_attr_setaffinity_np
82 sets the mask for the thread attribute object specified by
88 .Fn pthread_attr_getaffinity_np
90 .Fn pthread_attr_setaffinity_np
91 functions will return zero.
92 Otherwise an error number will be returned
93 to indicate the error.
96 .Fn pthread_attr_getaffinity_np
97 functions will fail if:
102 or the attribute specified by it is
111 .Fn pthread_attr_setaffinity_np
112 function will fail if:
117 or the attribute specified by it is
122 specified a CPU that was outside the set supported by the kernel.
128 Insufficient memory exists to store the cpuset mask.
135 .Xr pthread_get_affinity_np 3 ,
136 .Xr pthread_set_affinity_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 davidxu@FreeBSD.org ,
160 and this manpage was written by
161 .An Xin LI Aq delphij@FreeBSD.org .