Debian Codegraph @

upstream/debian-unstable/man3/sched_getcpu.3

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