]>
Commit | Line | Data |
---|---|---|
2b65a83f MK |
1 | .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
2b65a83f | 5 | .\" |
45186a5d | 6 | .TH SCHED_GETCPU 3 2021-03-22 "Linux man-pages (unreleased)" |
2b65a83f MK |
7 | .SH NAME |
8 | sched_getcpu \- determine CPU on which the calling thread is running | |
66985f1c AC |
9 | .SH LIBRARY |
10 | Standard C library | |
8fc3b2cf | 11 | .RI ( libc ", " \-lc ) |
2b65a83f MK |
12 | .SH SYNOPSIS |
13 | .nf | |
6a56bbb5 | 14 | .B #include <sched.h> |
dbfe9c70 | 15 | .PP |
2b65a83f MK |
16 | .B int sched_getcpu(void); |
17 | .fi | |
68e4db0a | 18 | .PP |
d39ad78f | 19 | .RS -4 |
cd05d2ff MK |
20 | Feature Test Macro Requirements for glibc (see |
21 | .BR feature_test_macros (7)): | |
d39ad78f | 22 | .RE |
68e4db0a | 23 | .PP |
cd05d2ff | 24 | .BR sched_getcpu (): |
9d2adbae MK |
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 | |
2b65a83f MK |
32 | .SH DESCRIPTION |
33 | .BR sched_getcpu () | |
15f0b7af AC |
34 | returns the number of the CPU |
35 | on which the calling thread is currently executing. | |
2b65a83f MK |
36 | .SH RETURN VALUE |
37 | On success, | |
38 | .BR sched_getcpu () | |
2fda57bd | 39 | returns a nonnegative CPU number. |
2b65a83f MK |
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 VERSIONS | |
49 | This function is available since glibc 2.6. | |
a7b3fac9 | 50 | .SH ATTRIBUTES |
a49469b7 PH |
51 | For an explanation of the terms used in this section, see |
52 | .BR attributes (7). | |
c466875e MK |
53 | .ad l |
54 | .nh | |
a49469b7 PH |
55 | .TS |
56 | allbox; | |
c466875e | 57 | lbx lb lb |
a49469b7 PH |
58 | l l l. |
59 | Interface Attribute Value | |
60 | T{ | |
a7b3fac9 | 61 | .BR sched_getcpu () |
a49469b7 PH |
62 | T} Thread safety MT-Safe |
63 | .TE | |
c466875e MK |
64 | .hy |
65 | .ad | |
66 | .sp 1 | |
3113c7f3 | 67 | .SH STANDARDS |
2b65a83f | 68 | .BR sched_getcpu () |
76c637e1 | 69 | is glibc-specific. |
2b65a83f MK |
70 | .SH NOTES |
71 | The call | |
e646a1ba | 72 | .PP |
2b65a83f | 73 | .in +4n |
e646a1ba | 74 | .EX |
2b65a83f | 75 | cpu = sched_getcpu(); |
e646a1ba | 76 | .EE |
2b65a83f | 77 | .in |
e646a1ba | 78 | .PP |
2b65a83f MK |
79 | is equivalent to the following |
80 | .BR getcpu (2) | |
81 | call: | |
e646a1ba | 82 | .PP |
2b65a83f | 83 | .in +4n |
e646a1ba | 84 | .EX |
2b65a83f MK |
85 | int c, s; |
86 | s = getcpu(&c, NULL, NULL); | |
c3074d70 | 87 | cpu = (s == \-1) ? s : c; |
b8302363 | 88 | .EE |
2b65a83f MK |
89 | .in |
90 | .SH SEE ALSO | |
6cc61889 MK |
91 | .BR getcpu (2), |
92 | .BR sched (7) |