aboutsummaryrefslogtreecommitdiff
path: root/share/man/man3/pthread_attr_affinity_np.3
blob: 8813f1a07dc991dc0227c54698f0eb2f9ad56389 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.\"-
.\" Copyright (c) 2010 Xin LI <delphij@FreeBSD.org>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd January 8, 2010
.Dt PTHREAD_ATTR_AFFINITY_NP 3
.Os
.Sh NAME
.Nm pthread_attr_getaffinity_np ,
.Nm pthread_attr_setaffinity_np
.Nd manage CPU affinity in thread attribute objects
.Sh LIBRARY
.Lb libpthread
.Sh SYNOPSIS
.In pthread_np.h
.Ft int
.Fn pthread_attr_getaffinity_np "const pthread_attr_t *pattr" "size_t cpusetsize" "cpuset_t *cpusetp"
.Ft int
.Fn pthread_attr_setaffinity_np "pthread_attr_t *pattr" "size_t cpusetsize" "const cpuset_t *cpusetp"
.Sh DESCRIPTION
The
.Fn pthread_attr_getaffinity_np
and
.Fn pthread_attr_setaffinity_np
functions allow the manipulation of sets of CPUs available to the specified thread attribute object.
.Pp
Masks of type
.Ft cpuset_t
are composed using the
.Xr CPU_SET 3
macros.
The kernel tolerates large sets as long as all CPUs specified
in the set exist.
Sets smaller than the kernel uses generate an error on calls to
.Fn pthread_attr_getaffinity_np
even if the result set would fit within the user supplied set.
Calls to
.Fn pthread_attr_setaffinity_np
tolerate small sets with no restrictions.
.Pp
The supplied mask should have a size of
.Fa cpusetsize
bytes.
This size is usually provided by calling
.Li sizeof(cpuset_t)
which is ultimately determined by the value of
.Dv CPU_SETSIZE
as defined in
.In sys/cpuset.h .
.Pp
.Fn pthread_attr_getaffinity_np
retrieves the
mask from the thread attribute object specified by
.Fa pattr ,
and stores it in the space provided by
.Fa cpusetp .
.Pp
.Fn pthread_attr_setaffinity_np
sets the mask for the thread attribute object specified by
.Fa pattr
to the value in
.Fa cpusetp .
.Sh RETURN VALUES
If successful, the
.Fn pthread_attr_getaffinity_np
and
.Fn pthread_attr_setaffinity_np
functions will return zero.
Otherwise an error number will be returned
to indicate the error.
.Sh ERRORS
The
.Fn pthread_attr_getaffinity_np
functions will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The
.Fa pattr
or the attribute specified by it is
.Dv NULL .
.It Bq Er ERANGE
The
.Fa cpusetsize
is too small.
.El
.Pp
The
.Fn pthread_attr_setaffinity_np
function will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The
.Fa pattr
or the attribute specified by it is
.Dv NULL .
.It Bq Er EINVAL
The
.Fa cpusetp
specified a CPU that was outside the set supported by the kernel.
.It Bq Er ERANGE
The
.Fa cpusetsize
is too small.
.It Bq Er ENOMEM
Insufficient memory exists to store the cpuset mask.
.El
.Sh SEE ALSO
.Xr cpuset 1 ,
.Xr cpuset 2 ,
.Xr cpuset_getid 2 ,
.Xr cpuset_setid 2 ,
.Xr CPU_SET 3 ,
.Xr pthread_get_affinity_np 3 ,
.Xr pthread_set_affinity_np 3
.Sh STANDARDS
The
.Nm pthread_attr_getaffinity_np
and
.Nm pthread_attr_setaffinity_np
functions are non-standard
.Fx
extensions and may be not available on other operating systems.
.Sh HISTORY
The
.Nm pthread_attr_getaffinity_np
and
.Nm pthread_attr_setaffinity_np
functions first appeared in
.Fx 7.2 .
.Sh AUTHORS
.An -nosplit
The
.Nm pthread_attr_getaffinity_np
and
.Nm pthread_attr_setaffinity_np
functions were written by
.An David Xu Aq davidxu@FreeBSD.org ,
and this manpage was written by
.An Xin LI Aq delphij@FreeBSD.org .