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
28 .Dt PTHREAD_AFFINITY_NP 3
31 .Nm pthread_getaffinity_np ,
32 .Nm pthread_setaffinity_np
33 .Nd manage CPU affinity
39 .Fn pthread_getaffinity_np "pthread_t td" "size_t cpusetsize" "cpuset_t *cpusetp"
41 .Fn pthread_setaffinity_np "pthread_t td" "size_t cpusetsize" "const cpuset_t *cpusetp"
43 .Fn pthread_getaffinity_np
45 .Fn pthread_setaffinity_np
46 allow the manipulation of sets of CPUs available to the specified thread.
50 are composed using the
53 The kernel tolerates large sets as long as all CPUs specified
55 Sets smaller than the kernel uses generate an error on calls to
56 .Fn pthread_getaffinity_np
57 even if the result set would fit within the user supplied set.
59 .Fn pthread_setaffinity_np
60 tolerate small sets with no restrictions.
62 The supplied mask should have a size of
65 This size is usually provided by calling
67 which is ultimately determined by the value of
72 .Fn pthread_getaffinity_np
74 mask from the thread specified by
76 and stores it in the space provided by
79 .Fn pthread_setaffinity_np
80 attempts to set the mask for the thread specified by
86 .Fn pthread_getaffinity_np
88 .Fn pthread_setaffinity_np
89 functions will return zero.
90 Otherwise an error number will be returned
91 to indicate the error.
94 .Fn pthread_getaffinity_np
96 .Fn pthread_setaffinity_np
97 functions may fail if:
101 .Fn pthread_setaffinity_np
102 call would leave a thread without a valid CPU to run on because the set
103 does not overlap with the thread's anonymous mask.
107 pointer passed was invalid.
109 The thread specified by the
111 argument could not be found.
115 was either preposterously large or smaller than the kernel set size.
117 The calling thread did not have the credentials required to complete the
126 .Xr pthread_attr_getaffinity_np 3 ,
127 .Xr pthread_attr_setaffinity_np 3
130 .Nm pthread_getaffinity_np
132 .Nm pthread_setaffinity_np
133 functions are non-standard
135 extensions and may be not available on other operating systems.
138 .Nm pthread_getaffinity_np
140 .Nm pthread_setaffinity_np
141 function first appeared in
146 .Nm pthread_getaffinity_np
148 .Nm pthread_setaffinity_np
149 functions were written by
150 .An David Xu Aq Mt davidxu@FreeBSD.org ,
151 and this manpage was written by
152 .An Xin LI Aq Mt delphij@FreeBSD.org .