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_AFFINITY_NP 3
29 .Nm pthread_getaffinity_np ,
30 .Nm pthread_setaffinity_np
31 .Nd manage CPU affinity
37 .Fn pthread_getaffinity_np "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp"
39 .Fn pthread_setaffinity_np "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp"
41 .Fn pthread_getaffinity_np
43 .Fn pthread_setaffinity_np
44 allow the manipulation of sets of CPUs available to the specified thread.
48 are composed using the
51 If the user-supplied mask is not large enough to fit all of the matching CPUs,
52 .Fn pthread_getaffinity_np
56 .Fn pthread_setaffinity_np
57 tolerate masks of any size with no restrictions.
58 The kernel uses the meaningful part of the mask, where the upper bound is
59 the maximum CPU id present in the system.
60 If bits for non-existing CPUs are set, calls to
61 .Fn pthread_setaffinity_np
65 The supplied mask should have a size of
68 This size is usually provided by calling
70 which is ultimately determined by the value of
75 .Fn pthread_getaffinity_np
77 mask from the thread specified by
79 and stores it in the space provided by
82 .Fn pthread_setaffinity_np
83 attempts to set the mask for the thread specified by
89 .Fn pthread_getaffinity_np
91 .Fn pthread_setaffinity_np
92 functions will return zero.
93 Otherwise an error number will be returned
94 to indicate the error.
97 .Fn pthread_getaffinity_np
99 .Fn pthread_setaffinity_np
100 functions may fail if:
105 argument specified when calling
106 .Fn pthread_setaffinity_np
107 was not a valid value.
110 .Fn pthread_setaffinity_np
111 call would leave a thread without a valid CPU to run on because the set
112 does not overlap with the thread's anonymous mask.
116 pointer passed was invalid.
118 The thread specified by the
120 argument could not be found.
124 was smaller than needed to fit all of the matching CPUs.
126 The calling thread did not have the credentials required to complete the
135 .Xr pthread_attr_getaffinity_np 3 ,
136 .Xr pthread_attr_setaffinity_np 3 ,
140 .Nm pthread_getaffinity_np
142 .Nm pthread_setaffinity_np
143 functions are non-standard
145 extensions and may be not available on other operating systems.
148 .Nm pthread_getaffinity_np
150 .Nm pthread_setaffinity_np
151 function first appeared in
156 .Nm pthread_getaffinity_np
158 .Nm pthread_setaffinity_np
159 functions were written by
160 .An David Xu Aq Mt davidxu@FreeBSD.org ,
161 and this manpage was written by
162 .An Xin LI Aq Mt delphij@FreeBSD.org .