This is an old revision of the document!
In a SMP system the property that binds processes to one or more processors by the OS scheduler is know as CPU affinity, the capability to override how the processes are assigned to a particular set of processors by the scheduler is a feature available in several OS. The idea is to say “always run this process on processor one” or “run these processes on all processors but processor zero”. The scheduler then obeys the order, and the process runs only on the allowed processors.
In the Linux case we have various mechanisms to set the CPU affinity
Linux provides a couple of system calls to set the and get the affinity of the current process, this are:
The official description on these system calls and data structures used can be obtain from The GNU C Library: CPU Affinity
The taskset command sets and checks affinity information for a given process. The manual page describes this command taskset
The isolcpus boot parameter can be used to specify CPUs to be isolated from the general SMP balancing and scheduler algorithms for user space processes. The isolcpus parameter will not impede the kernel scheduler to run kernel threads in the isolated cpu.
The syntax is of the isolcpus boot parameter is:
isolcpus=<cpu number>,….,<cpu number>
after boot we can use taskset command to assign a process to the isolated CPU
$ taskset -c <CPU NUMBER> -p <PID>