sched_getcpu
— get
current CPU
Standard C Library (libc, -lc)
#include
<sched.h>
int
sched_getcpu
(void);
The
sched_getcpu
()
function returns the current CPU on which the calling thread is running.
sched_getcpu
() returns the 0-based index
of the current CPU at the time of the call. The value may become invalid
immediately after return, unless the thread is pinned to a specific CPU. CPU
numbering is the same as used by
cpuset(2)
and CPU affinity calls.
There are no error values as
sched_getcpu
() does not fail.
The sched_getcpu
function originated in
Linux. This implementation aims to be source-compatible with the Linux
implementation.
The sched_getcpu
function was introduced
in FreeBSD 13.1.