share/mk/: build-html: Don't build mbind.2 and set_mempolicy.2
[man-pages.git] / man3 / pthread_attr_setaffinity_np.3
blob4d0df5763be5b8d0e408cdb05a5a9977722cb903
1 '\" t
2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH pthread_attr_setaffinity_np 3 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 pthread_attr_setaffinity_np, pthread_attr_getaffinity_np \- set/get
10 CPU affinity attribute in thread attributes object
11 .SH LIBRARY
12 POSIX threads library
13 .RI ( libpthread ", " \-lpthread )
14 .SH SYNOPSIS
15 .nf
16 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
17 .B #include <pthread.h>
19 .BI "int pthread_attr_setaffinity_np(pthread_attr_t *" attr ,
20 .BI "                   size_t " cpusetsize ", const cpu_set_t *" cpuset );
21 .BI "int pthread_attr_getaffinity_np(const pthread_attr_t *" attr ,
22 .BI "                   size_t " cpusetsize ", cpu_set_t *" cpuset );
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR pthread_attr_setaffinity_np ()
27 function
28 sets the CPU affinity mask attribute of the
29 thread attributes object referred to by
30 .I attr
31 to the value specified in
32 .IR cpuset .
33 This attribute determines the CPU affinity mask
34 of a thread created using the thread attributes object
35 .IR attr .
37 The
38 .BR pthread_attr_getaffinity_np ()
39 function
40 returns the CPU affinity mask attribute of the thread attributes object
41 referred to by
42 .I attr
43 in the buffer pointed to by
44 .IR cpuset .
46 The argument
47 .I cpusetsize
48 is the length (in bytes) of the buffer pointed to by
49 .IR cpuset .
50 Typically, this argument would be specified as
51 .IR sizeof(cpu_set_t) .
53 For more details on CPU affinity masks, see
54 .BR sched_setaffinity (2).
55 For a description of a set of macros
56 that can be used to manipulate and inspect CPU sets, see
57 .BR CPU_SET (3).
58 .SH RETURN VALUE
59 On success, these functions return 0;
60 on error, they return a nonzero error number.
61 .SH ERRORS
62 .TP
63 .B EINVAL
64 .RB ( pthread_attr_setaffinity_np ())
65 .I cpuset
66 specified a CPU that was outside the set supported by the kernel.
67 (The kernel configuration option
68 .B CONFIG_NR_CPUS
69 defines the range of the set supported by the kernel data type
70 .\" cpumask_t
71 used to represent CPU sets.)
72 .\" The raw sched_getaffinity() system call returns the size (in bytes)
73 .\" of the cpumask_t type.
74 .TP
75 .B EINVAL
76 .RB ( pthread_attr_getaffinity_np ())
77 A CPU in the affinity mask of the thread attributes object referred to by
78 .I attr
79 lies outside the range specified by
80 .I cpusetsize
81 (i.e.,
82 .IR cpuset / cpusetsize
83 is too small).
84 .TP
85 .B ENOMEM
86 .RB ( pthread_attr_setaffinity_np ())
87 Could not allocate memory.
88 .SH ATTRIBUTES
89 For an explanation of the terms used in this section, see
90 .BR attributes (7).
91 .TS
92 allbox;
93 lbx lb lb
94 l l l.
95 Interface       Attribute       Value
97 .na
98 .nh
99 .BR pthread_attr_setaffinity_np (),
100 .BR pthread_attr_getaffinity_np ()
101 T}      Thread safety   MT-Safe
103 .SH STANDARDS
104 GNU;
105 hence the suffix "_np" (nonportable) in the names.
106 .SH HISTORY
107 glibc 2.3.4.
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)