OSDN Git Service

c1775f23b350225f1332f8353a1ec3998a421f99
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_attr_setaffinity_np.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_ATTR_SETAFFINITY_NP 3 2010-09-10 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_attr_setaffinity_np, pthread_attr_getaffinity_np \- set/get
27 CPU affinity attribute in thread attributes object
28 .SH SYNOPSIS
29 .nf
30 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
31 .B #include <pthread.h>
32
33 .BI "int pthread_attr_setaffinity_np(pthread_attr_t *" attr ,
34 .BI "                   size_t " cpusetsize ", const cpu_set_t *" cpuset );
35 .BI "int pthread_attr_getaffinity_np(pthread_attr_t *" attr ,
36 .BI "                   size_t " cpusetsize ", cpu_set_t *" cpuset );
37 .sp
38 Compile and link with \fI\-pthread\fP.
39 .SH DESCRIPTION
40 The
41 .BR pthread_attr_setaffinity_np ()
42 function
43 sets the CPU affinity mask attribute of the
44 thread attributes object referred to by
45 .I attr
46 to the value specified in
47 .IR cpuset .
48 This attribute determines the CPU affinity mask
49 of a thread created using the thread attributes object
50 .IR attr .
51
52 The
53 .BR pthread_attr_getaffinity_np ()
54 function
55 returns the CPU affinity mask attribute of the thread attributes object
56 referred to by
57 .IR attr
58 in the buffer pointed to by
59 .IR cpuset .
60
61 The argument
62 .I cpusetsize
63 is the length (in bytes) of the buffer pointed to by
64 .IR cpuset .
65 Typically, this argument would be specified as
66 .IR sizeof(cpu_set_t) .
67
68 For more details on CPU affinity masks, see
69 .BR sched_setaffinity (2).
70 For a description of a set of macros
71 that can be used to manipulate and inspect CPU sets, see
72 .BR CPU_SET (3).
73 .SH RETURN VALUE
74 On success, these functions return 0;
75 on error, they return a nonzero error number.
76 .SH ERRORS
77 .TP
78 .BR EINVAL
79 .RB ( pthread_attr_setaffinity_np ())
80 .I cpuset
81 specified a CPU that was outside the set supported by the kernel.
82 (The kernel configuration option
83 .BR CONFIG_NR_CPUS
84 defines the range of the set supported by the kernel data type
85 .\" cpumask_t
86 used to represent CPU sets.)
87 .\" The raw sched_getaffinity() system call returns the size (in bytes)
88 .\" of the cpumask_t type.
89 .TP
90 .B EINVAL
91 .RB ( pthread_attr_getaffinity_np ())
92 A CPU in the affinity mask of the thread attributes object referred to by
93 .I attr
94 lies outside the range specified by
95 .IR cpusetsize
96 (i.e.,
97 .IR cpuset / cpusetsize
98 is too small).
99 .TP
100 .B ENOMEM
101 .RB ( pthread_attr_setaffinity_np ())
102 Could not allocate memory.
103 .SH VERSIONS
104 These functions are provided by glibc since version 2.3.4.
105 .SH CONFORMING TO
106 These functions are nonstandard GNU extensions;
107 hence the suffix "_np" (nonportable) in the names.
108 .SH NOTES
109 In glibc 2.3.3 only,
110 versions of these functions were provided that did not have a
111 .I cpusetsize
112 argument.
113 Instead the CPU set size given to the underlying system calls was always
114 .IR sizeof(cpu_set_t) .
115 .SH SEE ALSO
116 .BR sched_setaffinity (2),
117 .BR pthread_attr_init (3),
118 .BR pthread_setaffinity_np (3),
119 .BR cpuset (7),
120 .BR pthreads (7)