PTHREAD_CURCPU_NP(3) Library Functions Manual PTHREAD_CURCPU_NP(3)

pthread_curcpu_np
get current CPU identifier

#include <pthread.h>

unsigned int
pthread_curcpu_np(void);

The pthread_curcpu_np() function provides a way for a thread to know which CPU it's currently running on.

Note that, unless the thread is bound to a specific CPU, the result might be already stale when the function returns. However, it still can be useful as a hint to achieve better CPU locality.

The pthread_curcpu_np() function returns the integer identifier of the CPU which is currently running the calling thread.

The pthread_curcpu_np() function is a non-standard extension.

affinity(3), pthread(3)
November 10, 2011 NetBSD 9.2