]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man3/pthread_attr_affinity_np.3
Merge from projects/mips to head by hand:
[FreeBSD/FreeBSD.git] / share / man / man3 / pthread_attr_affinity_np.3
1 .\"-
2 .\" Copyright (c) 2010 Xin LI <delphij@FreeBSD.org>
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
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.
13 .\"
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
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd January 8, 2010
29 .Dt PTHREAD_ATTR_AFFINITY_NP 3
30 .Os
31 .Sh NAME
32 .Nm pthread_attr_getaffinity_np ,
33 .Nm pthread_attr_setaffinity_np
34 .Nd manage CPU affinity in thread attribute object
35 .Sh LIBRARY
36 .Lb libpthread
37 .Sh SYNOPSIS
38 .In pthread_np.h
39 .Ft int
40 .Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
41 .Ft int
42 .Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
43 .Sh DESCRIPTION
44 .Fn pthread_attr_getaffinity_np
45 and
46 .Fn pthread_attr_setaffinity_np
47 allow the manipulation of sets of CPUs available to specified thread attribute object.
48 .Pp
49 Masks of type
50 .Ft cpuset_t
51 are composed using the
52 .Xr CPU_SET 2
53 macros.
54 The kernel tolerates large sets as long as all CPUs specified
55 in the set exist.
56 Sets smaller than the kernel uses generate an error on calls to
57 .Fn  pthread_attr_getaffinity_np
58 even if the result set would fit within the user supplied set.
59 Calls to
60 .Fn pthread_attr_setaffinity_np
61 tolerate small sets with no restrictions.
62 .Pp
63 The supplied mask should have a size of
64 .Fa cpusetsize
65 bytes.
66 This size is usually provided by calling
67 .Li sizeof(cpuset_t)
68 which is ultimately determined by the value of
69 .Dv CPU_SETSIZE
70 as defined in
71 .In sys/cpuset.h .
72 .Pp
73 .Fn pthread_attr_getaffinity_np
74 retrieves the
75 mask from the thread attribute object specified by
76 .Fa pattr ,
77 and stores it in the space provided by
78 .Fa cpumaskp .
79 .Pp
80 .Fn pthread_attr_setaffinity_np
81 set the mask for the thread attribute object specified by
82 .Fa pattr
83 to the value in
84 .Fa cpumaskp .
85 .Pp
86 .Sh RETURN VALUES
87 If successful, the
88 .Fn pthread_attr_getaffinity_np
89 and
90 .Fn pthread_attr_setaffinity_np
91 functions will return zero.
92 Otherwise an error number will be returned
93 to indicate the error.
94 .Sh ERRORS
95 The
96 .Fn pthread_attr_getaffinity_np
97 and
98 .Fn pthread_attr_setaffinity_np
99 functions will fail if:
100 .Bl -tag -width Er
101 .It Bq Er EINVAL
102 The
103 .Fa pattr
104 or the attribute specified by it is NULL.
105 .El
106 .Pp
107 The
108 .Fn pthread_attr_setaffinity_np
109 function will fail if:
110 .Bl -tag -width Er
111 .It Bq Er EINVAL
112 The
113 .Fa pattr
114 or the attribute specified by it is NULL.
115 .It Bq Er ENOMEM
116 Insufficient memory exists to store the cpuset mask.
117 .El
118 .Sh SEE ALSO
119 .Xr cpuset 1 ,
120 .Xr cpuset 2 ,
121 .Xr cpuset_getid 2 ,
122 .Xr cpuset_setid 2 ,
123 .Xr CPU_SET 3 ,
124 .Xr pthread_get_affinity_np 3 ,
125 .Xr pthread_set_affinity_np 3 .
126 .Sh STANDARDS
127 The
128 .Nm pthread_attr_getaffinity_np
129 and
130 .Nm pthread_attr_setaffinity_np
131 functions are non-standard
132 .Fx
133 extensions and may be not available on other operating systems.
134 .Sh HISTORY
135 The
136 .Nm pthread_attr_getaffinity_np
137 and
138 .Nm pthread_attr_setaffinity_np
139 functions first appeared in
140 .Fx 7.2 .
141 .Sh AUTHORS
142 .An -nosplit
143 The
144 .Nm pthread_attr_getaffinity_np
145 and
146 .Nm pthread_attr_setaffinity_np
147 functions were written by
148 .An David Xu Aq davidxu@FreeBSD.org ,
149 and this manpage was written by
150 .An Xin LI Aq delphij@FreeBSD.org .