]>
Commit | Line | Data |
---|---|---|
2b65a83f MK |
1 | .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk |
2 | .\" <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
2b65a83f MK |
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. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
2b65a83f | 25 | .\" |
4b8c67d9 | 26 | .TH SCHED_GETCPU 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
2b65a83f MK |
27 | .SH NAME |
28 | sched_getcpu \- determine CPU on which the calling thread is running | |
29 | .SH SYNOPSIS | |
30 | .nf | |
6a56bbb5 | 31 | .B #include <sched.h> |
dbfe9c70 | 32 | .PP |
2b65a83f MK |
33 | .B int sched_getcpu(void); |
34 | .fi | |
68e4db0a | 35 | .PP |
cd05d2ff MK |
36 | .in -4n |
37 | Feature Test Macro Requirements for glibc (see | |
38 | .BR feature_test_macros (7)): | |
39 | .in | |
68e4db0a | 40 | .PP |
cd05d2ff MK |
41 | .BR sched_getcpu (): |
42 | .ad l | |
43 | .RS 4 | |
44 | .PD 0 | |
45 | .TP 4 | |
46 | Since glibc 2.14: | |
47 | _GNU_SOURCE | |
48 | .TP 4 | |
49 | Before glibc 2.14: | |
50 | _BSD_SOURCE || _SVID_SOURCE | |
51 | /* _GNU_SOURCE also suffices */ | |
52 | .PD | |
53 | .RE | |
54 | .ad b | |
2b65a83f MK |
55 | .SH DESCRIPTION |
56 | .BR sched_getcpu () | |
57 | returns the number of the CPU on which the calling thread is currently executing. | |
58 | .SH RETURN VALUE | |
59 | On success, | |
60 | .BR sched_getcpu () | |
2fda57bd | 61 | returns a nonnegative CPU number. |
2b65a83f MK |
62 | On error, \-1 is returned and |
63 | .I errno | |
64 | is set to indicate the error. | |
65 | .SH ERRORS | |
66 | .TP | |
67 | .B ENOSYS | |
68 | This kernel does not implement | |
69 | .BR getcpu (2). | |
70 | .SH VERSIONS | |
71 | This function is available since glibc 2.6. | |
a7b3fac9 | 72 | .SH ATTRIBUTES |
a49469b7 PH |
73 | For an explanation of the terms used in this section, see |
74 | .BR attributes (7). | |
75 | .TS | |
76 | allbox; | |
77 | lb lb lb | |
78 | l l l. | |
79 | Interface Attribute Value | |
80 | T{ | |
a7b3fac9 | 81 | .BR sched_getcpu () |
a49469b7 PH |
82 | T} Thread safety MT-Safe |
83 | .TE | |
2b65a83f MK |
84 | .SH CONFORMING TO |
85 | .BR sched_getcpu () | |
76c637e1 | 86 | is glibc-specific. |
2b65a83f MK |
87 | .SH NOTES |
88 | The call | |
e646a1ba | 89 | .PP |
2b65a83f | 90 | .in +4n |
e646a1ba | 91 | .EX |
2b65a83f | 92 | cpu = sched_getcpu(); |
e646a1ba | 93 | .EE |
2b65a83f | 94 | .in |
e646a1ba | 95 | .PP |
2b65a83f MK |
96 | is equivalent to the following |
97 | .BR getcpu (2) | |
98 | call: | |
e646a1ba | 99 | .PP |
2b65a83f | 100 | .in +4n |
e646a1ba | 101 | .EX |
2b65a83f MK |
102 | int c, s; |
103 | s = getcpu(&c, NULL, NULL); | |
c3074d70 | 104 | cpu = (s == \-1) ? s : c; |
b8302363 | 105 | .EE |
2b65a83f MK |
106 | .in |
107 | .SH SEE ALSO | |
6cc61889 MK |
108 | .BR getcpu (2), |
109 | .BR sched (7) |