mount_setattr.2: Minor tweaks to Christian's patch
[man-pages.git] / man3 / sched_getcpu.3
blobef0458b20062d2f2a456b80761a06e90e66c9ac0
1 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH SCHED_GETCPU 3 2021-03-22 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 sched_getcpu \- determine CPU on which the calling thread is running
29 .SH SYNOPSIS
30 .nf
31 .B #include <sched.h>
32 .PP
33 .B int sched_getcpu(void);
34 .fi
35 .PP
36 .RS -4
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .RE
40 .PP
41 .BR sched_getcpu ():
42 .nf
43     Since glibc 2.14:
44         _GNU_SOURCE
45     Before glibc 2.14:
46         _BSD_SOURCE || _SVID_SOURCE
47             /* _GNU_SOURCE also suffices */
48 .fi
49 .SH DESCRIPTION
50 .BR sched_getcpu ()
51 returns the number of the CPU on which the calling thread is currently executing.
52 .SH RETURN VALUE
53 On success,
54 .BR sched_getcpu ()
55 returns a nonnegative CPU number.
56 On error, \-1 is returned and
57 .I errno
58 is set to indicate the error.
59 .SH ERRORS
60 .TP
61 .B ENOSYS
62 This kernel does not implement
63 .BR getcpu (2).
64 .SH VERSIONS
65 This function is available since glibc 2.6.
66 .SH ATTRIBUTES
67 For an explanation of the terms used in this section, see
68 .BR attributes (7).
69 .ad l
70 .nh
71 .TS
72 allbox;
73 lbx lb lb
74 l l l.
75 Interface       Attribute       Value
77 .BR sched_getcpu ()
78 T}      Thread safety   MT-Safe
79 .TE
80 .hy
81 .ad
82 .sp 1
83 .SH CONFORMING TO
84 .BR sched_getcpu ()
85 is glibc-specific.
86 .SH NOTES
87 The call
88 .PP
89 .in +4n
90 .EX
91 cpu = sched_getcpu();
92 .EE
93 .in
94 .PP
95 is equivalent to the following
96 .BR getcpu (2)
97 call:
98 .PP
99 .in +4n
101 int c, s;
102 s = getcpu(&c, NULL, NULL);
103 cpu = (s == \-1) ? s : c;
106 .SH SEE ALSO
107 .BR getcpu (2),
108 .BR sched (7)