]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sched_getcpu.3
f116b2dfb3dced4436a1d96ee63536604829eead
[thirdparty/man-pages.git] / man3 / sched_getcpu.3
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 sched_getcpu 3 (date) "Linux man-pages (unreleased)"
8 .SH NAME
9 sched_getcpu \- determine CPU on which the calling thread is running
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ", " \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <sched.h>
16 .PP
17 .B int sched_getcpu(void);
18 .fi
19 .PP
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .PP
25 .BR sched_getcpu ():
26 .nf
27 Since glibc 2.14:
28 _GNU_SOURCE
29 Before glibc 2.14:
30 _BSD_SOURCE || _SVID_SOURCE
31 /* _GNU_SOURCE also suffices */
32 .fi
33 .SH DESCRIPTION
34 .BR sched_getcpu ()
35 returns the number of the CPU
36 on which the calling thread is currently executing.
37 .SH RETURN VALUE
38 On success,
39 .BR sched_getcpu ()
40 returns a nonnegative CPU number.
41 On error, \-1 is returned and
42 .I errno
43 is set to indicate the error.
44 .SH ERRORS
45 .TP
46 .B ENOSYS
47 This kernel does not implement
48 .BR getcpu (2).
49 .SH ATTRIBUTES
50 For an explanation of the terms used in this section, see
51 .BR attributes (7).
52 .ad l
53 .nh
54 .TS
55 allbox;
56 lbx lb lb
57 l l l.
58 Interface Attribute Value
59 T{
60 .BR sched_getcpu ()
61 T} Thread safety MT-Safe
62 .TE
63 .hy
64 .ad
65 .sp 1
66 .SH STANDARDS
67 GNU.
68 .SH HISTORY
69 glibc 2.6.
70 .SH NOTES
71 The call
72 .PP
73 .in +4n
74 .EX
75 cpu = sched_getcpu();
76 .EE
77 .in
78 .PP
79 is equivalent to the following
80 .BR getcpu (2)
81 call:
82 .PP
83 .in +4n
84 .EX
85 int c, s;
86 s = getcpu(&c, NULL, NULL);
87 cpu = (s == \-1) ? s : c;
88 .EE
89 .in
90 .SH SEE ALSO
91 .BR getcpu (2),
92 .BR sched (7)