Debian Codegraph @

upstream/debian-trixie/man3/sched_getcpu.3

raw
1 '\" t
2 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <[email protected]>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH sched_getcpu 3 2024-05-02 "Linux man-pages 6.9.1"
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 .P
17 .B int sched_getcpu(void);
18 .fi
19 .P
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
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 .TS
53 allbox;
54 lbx lb lb
55 l l l.
56 Interface Attribute Value
57 T{
58 .na
59 .nh
60 .BR sched_getcpu ()
61 T} Thread safety MT-Safe
62 .TE
63 .SH STANDARDS
64 GNU.
65 .SH HISTORY
66 glibc 2.6.
67 .SH NOTES
68 The call
69 .P
70 .in +4n
71 .EX
72 cpu = sched_getcpu();
73 .EE
74 .in
75 .P
76 is equivalent to the following
77 .BR getcpu (2)
78 call:
79 .P
80 .in +4n
81 .EX
82 int c, s;
83 s = getcpu(&c, NULL);
84 cpu = (s == \-1) ? s : c;
85 .EE
86 .in
87 .SH SEE ALSO
88 .BR getcpu (2),
89 .BR sched (7)