Binds the calling thread to a specified CPU, which results in hard affinity.
#include <nks/thread.h> int NXThreadBind ( NXCpuId_t cpu_id);
(IN) Specifies the ID of the CPU to be bound:
If successful, returns 0; otherwise, returns a nonzero error code:
A bound thread is scheduled only on the CPU to which it is bound. You can use the NXThreadBind function to bind a thread to a CPU, and with a subsequent call using the NX_THR_UNBOUND flag, remove that binding.
The NKS layer surfaces a simple naming scheme for the set of CPUs that are currently online by numbering them 0 through N-1 sequentially (with N being the number of CPUs online).
NXThreadBind is synchronous; on return, the calling thread is executed on the specified CPU.
Some worker thread pools may be set up on a per-processor basis. If the code that is being executed by one of those threads calls NXThreadBind, it defeats the purpose of creating per-processor worker thread pools. The application is responsible for controlling such a confusing situation.