#### 36.2.9.3 Thread CPU Affinity ¶

Processes and threads normally run on any available CPU. However, they can be given an affinity to one or more CPUs, which limits them to the CPU set specified.

Function: `int` pthread_attr_setaffinity_np `(pthread_attr_t *attr, size_t cpusetsize, const cpu_set_t *cpuset)` ¶

  Sets the CPU affinity in attr. The CPU affinity controls which CPUs a thread may execute on. See Limiting execution to certain CPUs. This documentation is a stub. For additional information on this function, consult the manual page pthread_attr_setaffinity_np(3) See Linux (The Linux Kernel).

Function: `int` pthread_attr_getaffinity_np `(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset)` ¶

  Gets the CPU affinity settings from attr. This documentation is a stub. For additional information on this function, consult the manual page pthread_attr_getaffinity_np(3) See Linux (The Linux Kernel).

Function: `int` pthread_setaffinity_np `(pthread_t *th, size_t cpusetsize, const cpu_set_t *cpuset)` ¶

  Sets the CPU affinity for thread th. The CPU affinity controls which CPUs a thread may execute on. See Limiting execution to certain CPUs. This documentation is a stub. For additional information on this function, consult the manual page pthread_setaffinity_np(3) See Linux (The Linux Kernel).

Function: `int` pthread_getaffinity_np `(const pthread_t *th, size_t cpusetsize, cpu_set_t *cpuset)` ¶

  Gets the CPU affinity for thread th. The CPU affinity controls which CPUs a thread may execute on. See Limiting execution to certain CPUs. This documentation is a stub. For additional information on this function, consult the manual page pthread_getaffinity_np(3) See Linux (The Linux Kernel).