LibX
This section isn't part of the official API. Things might change at any point without further notice.
Wrappers around some functionality provided by libc, libpthread, and libuv.
Index
ThreadPinning.getpidThreadPinning.getppidThreadPinning.gettidThreadPinning.pthread_set_affinity_maskThreadPinning.sched_getcpuThreadPinning.uv_cpumask_sizeThreadPinning.uv_thread_getaffinityThreadPinning.uv_thread_getaffinityThreadPinning.uv_thread_selfThreadPinning.uv_thread_setaffinityThreadPinning.uv_thread_setaffinity
References
ThreadPinning.uv_cpumask_size — MethodReturns the maximum size of the mask used for process/thread affinities, or UV_ENOTSUP if affinities are not supported on the current platform.
Ref: docs
ThreadPinning.uv_thread_getaffinity — Methoduv_thread_getaffinity(self_ref, cpumask, masksize)Gets the specified thread's affinity setting. On Unix, this maps the cpu_set_t returned by pthread_getaffinity_np(3) to bytes in cpumask.
The masksize specifies the number of entries (bytes) in cpumask, and must be greater-than-or-equal-to uv_cpumask_size.
Note: Thread affinity getting is not atomic on Windows and unsupported on macOS.
Ref: docs
ThreadPinning.uv_thread_getaffinity — Methoduv_thread_getaffinity()Query the calling thread's affinity.
ThreadPinning.uv_thread_self — MethodRef: docs
ThreadPinning.uv_thread_setaffinity — Methoduv_thread_setaffinity(self_ref, cpumask, oldmask, masksize)Sets the specified thread's affinity to cpumask, which is specified in bytes. Optionally returning the previous affinity setting in oldmask. On Unix, uses pthread_getaffinity_np(3) to get the affinity setting and maps the cpu_set_t to bytes in oldmask. Then maps the bytes in cpumask to a cpu_set_t and uses pthread_setaffinity_np(3). On Windows, maps the bytes in cpumask to a bitmask and uses SetThreadAffinityMask() which returns the previous affinity setting.
The masksize specifies the number of entries (bytes) in cpumask / oldmask, and must be greater-than-or-equal-to uv_cpumask_size().
Note: Thread affinity setting is not atomic on Windows and unsupported on macOS.
Ref: docs
ThreadPinning.uv_thread_setaffinity — Methoduv_thread_setaffinity(procid::Integer)Set the calling thread's affinity to procid.
ThreadPinning.getpid — MethodReturns the process ID (PID) of the calling process.
Ref: docs
ThreadPinning.getppid — MethodReturns the process ID of the parent of the calling process.
Ref: docs
ThreadPinning.gettid — MethodReturns the caller's thread ID (TID). In a single- threaded process, the thread ID is equal to the process ID (PID, as returned by getpid(2)). In a multithreaded process, all threads have the same PID, but each one has a unique TID.
Ref: docs
ThreadPinning.sched_getcpu — MethodReturns the number of the CPU on which the calling thread is currently executing.
Ref: docs
ThreadPinning.pthread_set_affinity_mask — MethodThe input mask should be either of the following:
- a
BitArrayindicating the mask directly - a vector of cpuids (the mask will be constructed automatically)