2 .\" Copyright (c) 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .TH sched_getcpu 3 (date) "Linux man-pages (unreleased)"
9 sched_getcpu \- determine CPU on which the calling thread is running
12 .RI ( libc ", " \-lc )
17 .B int sched_getcpu(void);
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
30 _BSD_SOURCE || _SVID_SOURCE
31 /* _GNU_SOURCE also suffices */
35 returns the number of the CPU
36 on which the calling thread is currently executing.
40 returns a nonnegative CPU number.
41 On error, \-1 is returned and
43 is set to indicate the error.
47 This kernel does not implement
50 For an explanation of the terms used in this section, see
58 Interface Attribute Value
61 T} Thread safety MT-Safe
79 is equivalent to the following
86 s = getcpu(&c, NULL, NULL);
87 cpu = (s == \-1) ? s : c;