OSDN Git Service

(split) LDP: Update original to LDP v3.38.
[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 .fi
40 .SH DESCRIPTION
41 The
42 .BR pthread_attr_setaffinity_np ()
43 function
44 sets the CPU affinity mask attribute of the
45 thread attributes object referred to by
46 .I attr
47 to the value specified in
48 .IR cpuset .
49 This attribute determines the CPU affinity mask
50 of a thread created using the thread attributes object
51 .IR attr .
52
53 The
54 .BR pthread_attr_getaffinity_np ()
55 function
56 returns the CPU affinity mask attribute of the thread attributes object
57 referred to by
58 .IR attr
59 in the buffer pointed to by
60 .IR cpuset .
61
62 The argument
63 .I cpusetsize
64 is the length (in bytes) of the buffer pointed to by
65 .IR cpuset .
66 Typically, this argument would be specified as
67 .IR sizeof(cpu_set_t) .
68
69 For more details on CPU affinity masks, see
70 .BR sched_setaffinity (2).
71 For a description of a set of macros
72 that can be used to manipulate and inspect CPU sets, see
73 .BR CPU_SET (3).
74 .SH RETURN VALUE
75 On success, these functions return 0;
76 on error, they return a nonzero error number.
77 .SH ERRORS
78 .TP
79 .BR EINVAL
80 .RB ( pthread_attr_setaffinity_np ())
81 .I cpuset
82 specified a CPU that was outside the set supported by the kernel.
83 (The kernel configuration option
84 .BR CONFIG_NR_CPUS
85 defines the range of the set supported by the kernel data type
86 .\" cpumask_t
87 used to represent CPU sets.)
88 .\" The raw sched_getaffinity() system call returns the size (in bytes)
89 .\" of the cpumask_t type.
90 .TP
91 .B EINVAL
92 .RB ( pthread_attr_getaffinity_np ())
93 A CPU in the affinity mask of the thread attributes object referred to by
94 .I attr
95 lies outside the range specified by
96 .IR cpusetsize
97 (i.e.,
98 .IR cpuset / cpusetsize
99 is too small).
100 .TP
101 .B ENOMEM
102 .RB ( pthread_attr_setaffinity_np ())
103 Could not allocate memory.
104 .SH VERSIONS
105 These functions are provided by glibc since version 2.3.4.
106 .SH CONFORMING TO
107 These functions are nonstandard GNU extensions;
108 hence the suffix "_np" (nonportable) in the names.
109 .SH NOTES
110 In glibc 2.3.3 only,
111 versions of these functions were provided that did not have a
112 .I cpusetsize
113 argument.
114 Instead the CPU set size given to the underlying system calls was always
115 .IR sizeof(cpu_set_t) .
116 .SH SEE ALSO
117 .BR sched_setaffinity (2),
118 .BR pthread_attr_init (3),
119 .BR pthread_setaffinity_np (3),
120 .BR cpuset (7),
121 .BR pthreads (7)