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