1*36887e04SEd Maste.\" SPDX-License-Identifier: BSD-2-Clause 2*36887e04SEd Maste.\" 3*36887e04SEd Maste.\" Copyright (c) 2024 The FreeBSD Foundation 4*36887e04SEd Maste.\" 5*36887e04SEd Maste.\" This documentation was written by Ed Maste <emaste@FreeBSD.org> 6*36887e04SEd Maste.\" under sponsorship from the FreeBSD Foundation. 7*36887e04SEd Maste.\" 8*36887e04SEd Maste.Dd November 13, 2024 9*36887e04SEd Maste.Dt SCHED_GETCPU 3 10*36887e04SEd Maste.Os 11*36887e04SEd Maste.Sh NAME 12*36887e04SEd Maste.Nm sched_getcpu 13*36887e04SEd Maste.Nd get current CPU 14*36887e04SEd Maste.Sh LIBRARY 15*36887e04SEd Maste.Lb libc 16*36887e04SEd Maste.Sh SYNOPSIS 17*36887e04SEd Maste.In sched.h 18*36887e04SEd Maste.Ft int 19*36887e04SEd Maste.Fn sched_getcpu void 20*36887e04SEd Maste.Sh DESCRIPTION 21*36887e04SEd MasteThe 22*36887e04SEd Maste.Fn sched_getcpu 23*36887e04SEd Mastefunction returns the current CPU on which the calling thread is running. 24*36887e04SEd Maste.Sh RETURN VALUES 25*36887e04SEd Maste.Fn sched_getcpu 26*36887e04SEd Mastereturns the 0-based index of the current CPU at the time of the call. 27*36887e04SEd MasteThe value may become invalid immediately after return, unless the thread is 28*36887e04SEd Mastepinned to a specific CPU. 29*36887e04SEd MasteCPU numbering is the same as used by 30*36887e04SEd Maste.Xr cpuset 2 31*36887e04SEd Masteand CPU affinity calls. 32*36887e04SEd Maste.Pp 33*36887e04SEd MasteThere are no error values as 34*36887e04SEd Maste.Fn sched_getcpu 35*36887e04SEd Mastedoes not fail. 36*36887e04SEd Maste.Sh SEE ALSO 37*36887e04SEd Maste.Xr cpuset 2 , 38*36887e04SEd Maste.Xr cpuset_getaffinity 2 , 39*36887e04SEd Maste.Xr cpuset_setaffinity 2 , 40*36887e04SEd Maste.Xr pthread_getaffinity_np 3 , 41*36887e04SEd Maste.Xr pthread_setaffinity_np 42*36887e04SEd Maste.Sh STANDARDS 43*36887e04SEd MasteThe 44*36887e04SEd Maste.Nm 45*36887e04SEd Mastefunction originated in Linux. 46*36887e04SEd MasteThis implementation aims to be source-compatible with the Linux implementation. 47*36887e04SEd Maste.Sh HISTORY 48*36887e04SEd MasteThe 49*36887e04SEd Maste.Nm 50*36887e04SEd Mastefunction was introduced in 51*36887e04SEd Maste.Fx 13.1 . 52