1SCHED_GETCPU(3)            Linux Programmer's Manual           SCHED_GETCPU(3)
2
3
4

NAME

6       sched_getcpu - determine CPU on which the calling thread is running
7

SYNOPSIS

9       #include <sched.h>
10
11       int sched_getcpu(void);
12
13   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15       sched_getcpu():
16           Since glibc 2.14:
17               _GNU_SOURCE
18           Before glibc 2.14:
19               _BSD_SOURCE || _SVID_SOURCE
20                   /* _GNU_SOURCE also suffices */
21

DESCRIPTION

23       sched_getcpu()  returns  the  number  of  the  CPU on which the calling
24       thread is currently executing.
25

RETURN VALUE

27       On success, sched_getcpu() returns a nonnegative CPU number.  On error,
28       -1 is returned and errno is set to indicate the error.
29

ERRORS

31       ENOSYS This kernel does not implement getcpu(2).
32

VERSIONS

34       This function is available since glibc 2.6.
35

ATTRIBUTES

37       For   an   explanation   of   the  terms  used  in  this  section,  see
38       attributes(7).
39
40       ┌───────────────┬───────────────┬─────────┐
41Interface      Attribute     Value   
42       ├───────────────┼───────────────┼─────────┤
43sched_getcpu() │ Thread safety │ MT-Safe │
44       └───────────────┴───────────────┴─────────┘

CONFORMING TO

46       sched_getcpu() is glibc-specific.
47

NOTES

49       The call
50
51           cpu = sched_getcpu();
52
53       is equivalent to the following getcpu(2) call:
54
55           int c, s;
56           s = getcpu(&c, NULL, NULL);
57           cpu = (s == -1) ? s : c;
58

SEE ALSO

60       getcpu(2), sched(7)
61

COLOPHON

63       This page is part of release 5.07 of the Linux  man-pages  project.   A
64       description  of  the project, information about reporting bugs, and the
65       latest    version    of    this    page,    can     be     found     at
66       https://www.kernel.org/doc/man-pages/.
67
68
69
70Linux                             2017-09-15                   SCHED_GETCPU(3)
Impressum