pthread_attr_setcpu_np3
Examine and change the cpu pthread attribute
Usage
#include <rtl_sched.h>
int pthread_sttr_setcpu_np(pthread_attr_t *attr, int cpu); int pthread_sttr_getcpu_np(pthread_attr_t *attr, int *cpu);
Overview
These functions are non-portable Real-Time Linux extensions. On SMP machines they allow a thread to be scheduled on a specific CPU.
pthread_attr_setcpu_np modifies the thread attribute object attribute so that the created thread would be scheduled on the CPU with id cpu (as displayed in /proc/cpuinfo ). The thread attribute object attr first has to be initialized with pthread_attr_init(3).
pthread_attr_getcpu_np fills the location pointed to by cpu with the CPU id from the attribute structure.
Return value
All functions return 0 on success and a non-zero error code on error.
Errors
pthread_attr_getcpu_np returns EINVAL if the specified CPU does not exist in the system.
Notes
If pthread_attr_setcpu_np was not used on the attribute object passed to pthread_create, the thread is scheduled on the current CPU.