]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/sched_getcpu.3
_syscall.2, accept.2, epoll_create.2, inotify_add_watch.2, ioctl.2, msgget.2, msgop...
[thirdparty/man-pages.git] / 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 2009-12-08 "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 .B #define _GNU_SOURCE
30 .B #include <sched.h>
31
32 .B int sched_getcpu(void);
33 .fi
34 .sp
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .sp
40 .BR sched_getcpu ():
41 _BSD_SOURCE || _SVID_SOURCE
42 .SH DESCRIPTION
43 .BR sched_getcpu ()
44 returns the number of the CPU on which the calling thread is currently executing.
45 .SH RETURN VALUE
46 On success,
47 .BR sched_getcpu ()
48 returns a nonnegative CPU number.
49 On error, \-1 is returned and
50 .I errno
51 is set to indicate the error.
52 .SH ERRORS
53 .TP
54 .B ENOSYS
55 This kernel does not implement
56 .BR getcpu (2).
57 .SH VERSIONS
58 This function is available since glibc 2.6.
59 .SH CONFORMING TO
60 .BR sched_getcpu ()
61 is glibc specific.
62 .SH NOTES
63 The call
64 .in +4n
65 .nf
66
67 cpu = sched_getcpu();
68
69 .fi
70 .in
71 is equivalent to the following
72 .BR getcpu (2)
73 call:
74 .in +4n
75 .nf
76
77 int c, s;
78 s = getcpu(&c, NULL, NULL);
79 cpu = (s == -1) ? s : c;
80 .fi
81 .in
82 .SH SEE ALSO
83 .BR getcpu (2)