OSDN Git Service

(split) LDP: Update original to LDP v3.65
[linuxjm/LDP_man-pages.git] / original / man3 / sched_getcpu.3
1 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
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.
24 .\" %%%LICENSE_END
25 .\"
26 .TH SCHED_GETCPU 3 2013-04-17 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 sched_getcpu \- determine CPU on which the calling thread is running
29 .SH SYNOPSIS
30 .nf
31 .B #include <sched.h>
32
33 .B int sched_getcpu(void);
34 .fi
35 .sp
36 .in -4n
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .in
40 .sp
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
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 ()
61 returns a nonnegative CPU number.
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.
72 .SH CONFORMING TO
73 .BR sched_getcpu ()
74 is glibc-specific.
75 .SH NOTES
76 The call
77 .in +4n
78 .nf
79
80 cpu = sched_getcpu();
81
82 .fi
83 .in
84 is equivalent to the following
85 .BR getcpu (2)
86 call:
87 .in +4n
88 .nf
89
90 int c, s;
91 s = getcpu(&c, NULL, NULL);
92 cpu = (s == \-1) ? s : c;
93 .fi
94 .in
95 .SH SEE ALSO
96 .BR getcpu (2)
97 .SH COLOPHON
98 This page is part of release 3.65 of the Linux
99 .I man-pages
100 project.
101 A description of the project,
102 and information about reporting bugs,
103 can be found at
104 \%http://www.kernel.org/doc/man\-pages/.