1sched_getcpu(3)            Library Functions Manual            sched_getcpu(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

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

DESCRIPTION

26       sched_getcpu()  returns  the  number  of  the  CPU on which the calling
27       thread is currently executing.
28

RETURN VALUE

30       On success, sched_getcpu() returns a nonnegative CPU number.  On error,
31       -1 is returned and errno is set to indicate the error.
32

ERRORS

34       ENOSYS This kernel does not implement getcpu(2).
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

STANDARDS

47       GNU.
48

HISTORY

50       glibc 2.6.
51

NOTES

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

SEE ALSO

64       getcpu(2), sched(7)
65
66
67
68Linux man-pages 6.04              2023-03-30                   sched_getcpu(3)
Impressum