]> git.ipfire.org Git - thirdparty/man-pages.git/blame_incremental - man3/sched_getcpu.3
dlopen.3: tfix
[thirdparty/man-pages.git] / man3 / sched_getcpu.3
... / ...
CommitLineData
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 2017-09-15 "Linux" "Linux Programmer's Manual"
27.SH NAME
28sched_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.in -4n
37Feature Test Macro Requirements for glibc (see
38.BR feature_test_macros (7)):
39.in
40.PP
41.BR sched_getcpu ():
42.ad l
43.RS 4
44.PD 0
45.TP 4
46Since glibc 2.14:
47_GNU_SOURCE
48.TP 4
49Before glibc 2.14:
50_BSD_SOURCE || _SVID_SOURCE
51 /* _GNU_SOURCE also suffices */
52.PD
53.RE
54.ad b
55.SH DESCRIPTION
56.BR sched_getcpu ()
57returns the number of the CPU on which the calling thread is currently executing.
58.SH RETURN VALUE
59On success,
60.BR sched_getcpu ()
61returns a nonnegative CPU number.
62On error, \-1 is returned and
63.I errno
64is set to indicate the error.
65.SH ERRORS
66.TP
67.B ENOSYS
68This kernel does not implement
69.BR getcpu (2).
70.SH VERSIONS
71This function is available since glibc 2.6.
72.SH ATTRIBUTES
73For an explanation of the terms used in this section, see
74.BR attributes (7).
75.TS
76allbox;
77lb lb lb
78l l l.
79Interface Attribute Value
80T{
81.BR sched_getcpu ()
82T} Thread safety MT-Safe
83.TE
84.SH CONFORMING TO
85.BR sched_getcpu ()
86is glibc-specific.
87.SH NOTES
88The call
89.PP
90.in +4n
91.EX
92cpu = sched_getcpu();
93.EE
94.in
95.PP
96is equivalent to the following
97.BR getcpu (2)
98call:
99.PP
100.in +4n
101.EX
102int c, s;
103s = getcpu(&c, NULL, NULL);
104cpu = (s == \-1) ? s : c;
105.EE
106.in
107.SH SEE ALSO
108.BR getcpu (2),
109.BR sched (7)