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 at‐
38       tributes(7).
39
40       ┌────────────────────────────────────────────┬───────────────┬─────────┐
41Interface                                   Attribute     Value   
42       ├────────────────────────────────────────────┼───────────────┼─────────┤
43sched_getcpu()                              │ Thread safety │ MT-Safe │
44       └────────────────────────────────────────────┴───────────────┴─────────┘
45

CONFORMING TO

47       sched_getcpu() is glibc-specific.
48

NOTES

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

SEE ALSO

61       getcpu(2), sched(7)
62

COLOPHON

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