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_AFFINITY_NP 3
32 .Nm pthread_getaffinity_np ,
33 .Nm pthread_setaffinity_np
34 .Nd manage CPU affinity
40 .Fn pthread_getaffinity_np "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp"
42 .Fn pthread_setaffinity_np "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp"
44 .Fn pthread_getaffinity_np
46 .Fn pthread_setaffinity_np
47 allow the manipulation of sets of CPUs available to the specified thread.
51 are composed using the
54 The kernel tolerates large sets as long as all CPUs specified
56 Sets smaller than the kernel uses generate an error on calls to
57 .Fn pthread_getaffinity_np
58 even if the result set would fit within the user supplied set.
60 .Fn pthread_setaffinity_np
61 tolerate small sets with no restrictions.
63 The supplied mask should have a size of
66 This size is usually provided by calling
68 which is ultimately determined by the value of
73 .Fn pthread_getaffinity_np
75 mask from the thread specified by
77 and stores it in the space provided by
80 .Fn pthread_setaffinity_np
81 attempts to set the mask for the thread specified by
87 .Fn pthread_getaffinity_np
89 .Fn pthread_setaffinity_np
90 functions will return zero.
91 Otherwise an error number will be returned
92 to indicate the error.
95 .Fn pthread_getaffinity_np
97 .Fn pthread_setaffinity_np
98 functions may fail if:
102 .Fn pthread_setaffinity_np
103 call would leave a thread without a valid CPU to run on because the set
104 does not overlap with the thread's anonymous mask.
108 pointer passed was invalid.
110 The thread specified by the
112 argument could not be found.
116 was either preposterously large or smaller than the kernel set size.
118 The calling thread did not have the credentials required to complete the
128 .Xr pthread_attr_getaffinity_np 3 ,
129 .Xr pthread_attr_setaffinity_np 3
132 .Nm pthread_getaffinity_np
134 .Nm pthread_setaffinity_np
135 functions are non-standard
137 extensions and may be not available on other operating systems.
140 .Nm pthread_getaffinity_np
142 .Nm pthread_setaffinity_np
143 function first appeared in
148 .Nm pthread_getaffinity_np
150 .Nm pthread_setaffinity_np
151 functions were written by
153 .Aq davidxu@FreeBSD.org ,
154 and this manpage was written by
156 .Aq delphij@FreeBSD.org .