OSDN Git Service

(split) LDP_man-pages: update original to v3.34.
[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 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH SCHED_GETCPU 3 2010-10-31 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 sched_getcpu \- determine CPU on which the calling thread is running
27 .SH SYNOPSIS
28 .nf
29 .BR "#define _GNU_SOURCE" "         /* See feature_test_macros(7) */"
30 .\" Really:_BSD_SOURCE || _SVID_SOURCE
31 .B #include <sched.h>
32
33 .B int sched_getcpu(void);
34 .fi
35 .SH DESCRIPTION
36 .BR sched_getcpu ()
37 returns the number of the CPU on which the calling thread is currently executing.
38 .SH RETURN VALUE
39 On success,
40 .BR sched_getcpu ()
41 returns a nonnegative CPU number.
42 On error, \-1 is returned and
43 .I errno
44 is set to indicate the error.
45 .SH ERRORS
46 .TP
47 .B ENOSYS
48 This kernel does not implement
49 .BR getcpu (2).
50 .SH VERSIONS
51 This function is available since glibc 2.6.
52 .SH CONFORMING TO
53 .BR sched_getcpu ()
54 is glibc specific.
55 .SH NOTES
56 The call
57 .in +4n
58 .nf
59
60 cpu = sched_getcpu();
61
62 .fi
63 .in
64 is equivalent to the following
65 .BR getcpu (2)
66 call:
67 .in +4n
68 .nf
69
70 int c, s;
71 s = getcpu(&c, NULL, NULL);
72 cpu = (s == \-1) ? s : c;
73 .fi
74 .in
75 .SH SEE ALSO
76 .BR getcpu (2)