xref: /freebsd/share/man/man3/pthread_attr_affinity_np.3 (revision 1200ef56b51f58505340b5af796552b04d68b0f4)
1777f8cebSXin LI.\"-
2777f8cebSXin LI.\" Copyright (c) 2010 Xin LI <delphij@FreeBSD.org>
3777f8cebSXin LI.\" All rights reserved.
4777f8cebSXin LI.\"
5777f8cebSXin LI.\" Redistribution and use in source and binary forms, with or without
6777f8cebSXin LI.\" modification, are permitted provided that the following conditions
7777f8cebSXin LI.\" are met:
8777f8cebSXin LI.\" 1. Redistributions of source code must retain the above copyright
9777f8cebSXin LI.\"    notice, this list of conditions and the following disclaimer.
10777f8cebSXin LI.\" 2. Redistributions in binary form must reproduce the above copyright
11777f8cebSXin LI.\"    notice, this list of conditions and the following disclaimer in the
12777f8cebSXin LI.\"    documentation and/or other materials provided with the distribution.
13777f8cebSXin LI.\"
14777f8cebSXin LI.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15777f8cebSXin LI.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16777f8cebSXin LI.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17777f8cebSXin LI.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18777f8cebSXin LI.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19777f8cebSXin LI.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20777f8cebSXin LI.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21777f8cebSXin LI.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22777f8cebSXin LI.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23777f8cebSXin LI.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24777f8cebSXin LI.\" SUCH DAMAGE.
25777f8cebSXin LI.\"
26777f8cebSXin LI.\" $FreeBSD$
27777f8cebSXin LI.\"
28777f8cebSXin LI.Dd January 8, 2010
29777f8cebSXin LI.Dt PTHREAD_ATTR_AFFINITY_NP 3
30777f8cebSXin LI.Os
31777f8cebSXin LI.Sh NAME
32777f8cebSXin LI.Nm pthread_attr_getaffinity_np ,
33777f8cebSXin LI.Nm pthread_attr_setaffinity_np
34d49bbd73SChristian Brueffer.Nd manage CPU affinity in thread attribute objects
35777f8cebSXin LI.Sh LIBRARY
36777f8cebSXin LI.Lb libpthread
37777f8cebSXin LI.Sh SYNOPSIS
38777f8cebSXin LI.In pthread_np.h
39777f8cebSXin LI.Ft int
40777f8cebSXin LI.Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
41777f8cebSXin LI.Ft int
42777f8cebSXin LI.Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
43777f8cebSXin LI.Sh DESCRIPTION
44d49bbd73SChristian BruefferThe
45777f8cebSXin LI.Fn pthread_attr_getaffinity_np
46777f8cebSXin LIand
47777f8cebSXin LI.Fn pthread_attr_setaffinity_np
48d49bbd73SChristian Bruefferfunctions allow the manipulation of sets of CPUs available to the specified thread attribute object.
49777f8cebSXin LI.Pp
50777f8cebSXin LIMasks of type
51777f8cebSXin LI.Ft cpuset_t
52777f8cebSXin LIare composed using the
53d49bbd73SChristian Brueffer.Xr CPU_SET 3
54777f8cebSXin LImacros.
55777f8cebSXin LIThe kernel tolerates large sets as long as all CPUs specified
56777f8cebSXin LIin the set exist.
57777f8cebSXin LISets smaller than the kernel uses generate an error on calls to
58777f8cebSXin LI.Fn pthread_attr_getaffinity_np
59777f8cebSXin LIeven if the result set would fit within the user supplied set.
60777f8cebSXin LICalls to
61777f8cebSXin LI.Fn pthread_attr_setaffinity_np
62777f8cebSXin LItolerate small sets with no restrictions.
63777f8cebSXin LI.Pp
64777f8cebSXin LIThe supplied mask should have a size of
65777f8cebSXin LI.Fa cpusetsize
66777f8cebSXin LIbytes.
67777f8cebSXin LIThis size is usually provided by calling
68777f8cebSXin LI.Li sizeof(cpuset_t)
69777f8cebSXin LIwhich is ultimately determined by the value of
70777f8cebSXin LI.Dv CPU_SETSIZE
71777f8cebSXin LIas defined in
72777f8cebSXin LI.In sys/cpuset.h .
73777f8cebSXin LI.Pp
74777f8cebSXin LI.Fn pthread_attr_getaffinity_np
75777f8cebSXin LIretrieves the
76777f8cebSXin LImask from the thread attribute object specified by
77777f8cebSXin LI.Fa pattr ,
78777f8cebSXin LIand stores it in the space provided by
79d49bbd73SChristian Brueffer.Fa cpusetp .
80777f8cebSXin LI.Pp
81777f8cebSXin LI.Fn pthread_attr_setaffinity_np
82d49bbd73SChristian Brueffersets the mask for the thread attribute object specified by
83777f8cebSXin LI.Fa pattr
84777f8cebSXin LIto the value in
85d49bbd73SChristian Brueffer.Fa cpusetp .
86777f8cebSXin LI.Sh RETURN VALUES
87777f8cebSXin LIIf successful, the
88777f8cebSXin LI.Fn pthread_attr_getaffinity_np
89777f8cebSXin LIand
90777f8cebSXin LI.Fn pthread_attr_setaffinity_np
91777f8cebSXin LIfunctions will return zero.
92777f8cebSXin LIOtherwise an error number will be returned
93777f8cebSXin LIto indicate the error.
94777f8cebSXin LI.Sh ERRORS
95777f8cebSXin LIThe
96777f8cebSXin LI.Fn pthread_attr_getaffinity_np
97777f8cebSXin LIfunctions will fail if:
98777f8cebSXin LI.Bl -tag -width Er
99777f8cebSXin LI.It Bq Er EINVAL
100777f8cebSXin LIThe
101777f8cebSXin LI.Fa pattr
102d49bbd73SChristian Bruefferor the attribute specified by it is
103d49bbd73SChristian Brueffer.Dv NULL .
104*1200ef56SDavid Xu.It Bq Er ERANGE
105*1200ef56SDavid XuThe
106*1200ef56SDavid Xu.Fa cpusetsize
107*1200ef56SDavid Xuis too small.
108777f8cebSXin LI.El
109777f8cebSXin LI.Pp
110777f8cebSXin LIThe
111777f8cebSXin LI.Fn pthread_attr_setaffinity_np
112777f8cebSXin LIfunction will fail if:
113777f8cebSXin LI.Bl -tag -width Er
114777f8cebSXin LI.It Bq Er EINVAL
115777f8cebSXin LIThe
116777f8cebSXin LI.Fa pattr
117d49bbd73SChristian Bruefferor the attribute specified by it is
118d49bbd73SChristian Brueffer.Dv NULL .
119*1200ef56SDavid Xu.It Bq Er EINVAL
120*1200ef56SDavid XuThe
121*1200ef56SDavid Xu.Fa cpusetp
122*1200ef56SDavid Xuspecified a CPU that was outside the set supported by the kernel.
123*1200ef56SDavid Xu.It Bq Er ERANGE
124*1200ef56SDavid XuThe
125*1200ef56SDavid Xu.Fa cpusetsize
126*1200ef56SDavid Xuis too small.
127777f8cebSXin LI.It Bq Er ENOMEM
128777f8cebSXin LIInsufficient memory exists to store the cpuset mask.
129777f8cebSXin LI.El
130777f8cebSXin LI.Sh SEE ALSO
131777f8cebSXin LI.Xr cpuset 1 ,
132777f8cebSXin LI.Xr cpuset 2 ,
133777f8cebSXin LI.Xr cpuset_getid 2 ,
134777f8cebSXin LI.Xr cpuset_setid 2 ,
135777f8cebSXin LI.Xr CPU_SET 3 ,
136777f8cebSXin LI.Xr pthread_get_affinity_np 3 ,
137d49bbd73SChristian Brueffer.Xr pthread_set_affinity_np 3
138777f8cebSXin LI.Sh STANDARDS
139777f8cebSXin LIThe
140777f8cebSXin LI.Nm pthread_attr_getaffinity_np
141777f8cebSXin LIand
142777f8cebSXin LI.Nm pthread_attr_setaffinity_np
143777f8cebSXin LIfunctions are non-standard
144777f8cebSXin LI.Fx
145777f8cebSXin LIextensions and may be not available on other operating systems.
146777f8cebSXin LI.Sh HISTORY
147777f8cebSXin LIThe
148777f8cebSXin LI.Nm pthread_attr_getaffinity_np
149777f8cebSXin LIand
150777f8cebSXin LI.Nm pthread_attr_setaffinity_np
151777f8cebSXin LIfunctions first appeared in
152777f8cebSXin LI.Fx 7.2 .
153777f8cebSXin LI.Sh AUTHORS
154777f8cebSXin LI.An -nosplit
155777f8cebSXin LIThe
156777f8cebSXin LI.Nm pthread_attr_getaffinity_np
157777f8cebSXin LIand
158777f8cebSXin LI.Nm pthread_attr_setaffinity_np
159777f8cebSXin LIfunctions were written by
160777f8cebSXin LI.An David Xu Aq davidxu@FreeBSD.org ,
161777f8cebSXin LIand this manpage was written by
162777f8cebSXin LI.An Xin LI Aq delphij@FreeBSD.org .
163