]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - share/man/man3/pthread_attr_affinity_np.3
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.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 objects
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 The
45 .Fn pthread_attr_getaffinity_np
46 and
47 .Fn pthread_attr_setaffinity_np
48 functions allow the manipulation of sets of CPUs available to the specified thread attribute object.
49 .Pp
50 Masks of type
51 .Ft cpuset_t
52 are composed using the
53 .Xr CPU_SET 3
54 macros.
55 The kernel tolerates large sets as long as all CPUs specified
56 in the set exist.
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.
60 Calls to
61 .Fn pthread_attr_setaffinity_np
62 tolerate small sets with no restrictions.
63 .Pp
64 The supplied mask should have a size of
65 .Fa cpusetsize
66 bytes.
67 This size is usually provided by calling
68 .Li sizeof(cpuset_t)
69 which is ultimately determined by the value of
70 .Dv CPU_SETSIZE
71 as defined in
72 .In sys/cpuset.h .
73 .Pp
74 .Fn pthread_attr_getaffinity_np
75 retrieves the
76 mask from the thread attribute object specified by
77 .Fa pattr ,
78 and stores it in the space provided by
79 .Fa cpusetp .
80 .Pp
81 .Fn pthread_attr_setaffinity_np
82 sets the mask for the thread attribute object specified by
83 .Fa pattr
84 to the value in
85 .Fa cpusetp .
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
105 .Dv NULL .
106 .El
107 .Pp
108 The
109 .Fn pthread_attr_setaffinity_np
110 function will fail if:
111 .Bl -tag -width Er
112 .It Bq Er EINVAL
113 The
114 .Fa pattr
115 or the attribute specified by it is
116 .Dv NULL .
117 .It Bq Er ENOMEM
118 Insufficient memory exists to store the cpuset mask.
119 .El
120 .Sh SEE ALSO
121 .Xr cpuset 1 ,
122 .Xr cpuset 2 ,
123 .Xr cpuset_getid 2 ,
124 .Xr cpuset_setid 2 ,
125 .Xr CPU_SET 3 ,
126 .Xr pthread_get_affinity_np 3 ,
127 .Xr pthread_set_affinity_np 3
128 .Sh STANDARDS
129 The
130 .Nm pthread_attr_getaffinity_np
131 and
132 .Nm pthread_attr_setaffinity_np
133 functions are non-standard
134 .Fx
135 extensions and may be not available on other operating systems.
136 .Sh HISTORY
137 The
138 .Nm pthread_attr_getaffinity_np
139 and
140 .Nm pthread_attr_setaffinity_np
141 functions first appeared in
142 .Fx 7.2 .
143 .Sh AUTHORS
144 .An -nosplit
145 The
146 .Nm pthread_attr_getaffinity_np
147 and
148 .Nm pthread_attr_setaffinity_np
149 functions were written by
150 .An David Xu Aq davidxu@FreeBSD.org ,
151 and this manpage was written by
152 .An Xin LI Aq delphij@FreeBSD.org .