October 2017
Intermediate to advanced
354 pages
9h 28m
English
Linux-specific processor affinity calls are provided, which help the threads define on which CPU(s) they want to run. By default, every thread inherits the processor affinity of its parent, but it can define its affinity mask to determine its processor affinity. On many-core systems, CPU affinity calls help in enhancing the performance, by helping the process stick to one core (Linux however attempts to keep a thread on one CPU). The affinity bitmask information is contained in the cpu_allowed field of struct task_struct. The affinity calls are as follows:
sched_setaffinity(pid_t pid, size_t cpusetsize, const cpu_set_t *mask)
It sets the CPU affinity mask of the thread (pid) to the value mentioned by mask. If the ...