OSDN Git Service

LDP: Update original to LDP v3.68
[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 2014-05-10 "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 ATTRIBUTES
73 .SS Multithreading (see pthreads(7))
74 The
75 .BR sched_getcpu ()
76 function is thread-safe.
77 .SH CONFORMING TO
78 .BR sched_getcpu ()
79 is glibc-specific.
80 .SH NOTES
81 The call
82 .in +4n
83 .nf
84
85 cpu = sched_getcpu();
86
87 .fi
88 .in
89 is equivalent to the following
90 .BR getcpu (2)
91 call:
92 .in +4n
93 .nf
94
95 int c, s;
96 s = getcpu(&c, NULL, NULL);
97 cpu = (s == \-1) ? s : c;
98 .fi
99 .in
100 .SH SEE ALSO
101 .BR getcpu (2),
102 .BR sched (7)
103 .SH COLOPHON
104 This page is part of release 3.68 of the Linux
105 .I man-pages
106 project.
107 A description of the project,
108 information about reporting bugs,
109 and the latest version of this page,
110 can be found at
111 \%http://www.kernel.org/doc/man\-pages/.