Function to get/set the process's CPU affinity mask. Affinity mask allows binding a process to a specific core(s) within the machine.
1 2 3 4 5 6 7
Which cpu cores to restrict to. Must be vector of integers between 1 and ncores.
print some C output (TRUE/FALSE)
Setting a process afinity allows for restricting the process to only use certain cores in the machine. The cores are indexed by the operating system as 1 to ncores. One can lookup ncores using ncores(). Calling setaffinity with no arguments resets the process to use any of the available cores.
Note that setaffinity is different from setting r_limit values in the sense that it is not a one-way process. An unprivileged user can change the process affinity to any value. In order to 'lock' an affinity value, one would have to manipulate Linux capability value for CAP_SYS_NICE.
Jeroen Ooms (2013). The RAppArmor Package: Enforcing Security Policies in R Using Dynamic Sandboxing on Linux. Journal of Statistical Software, 55(7), 1-34. http://www.jstatsoft.org/v55/i07/.
sched_setaffinity - set and get a process's CPU affinity mask.
1 2 3 4 5 6 7 8 9 10