Until the late 90s, most of the computers came only with a single-core processor (also called uniprocessor) like Intel Pentium 3. But newer processors are all multi-core processors (also called multiprocessor). The obvious benefit of a multi-core processor is that all the processing can be divided and shared by different cores at the same time, making the processing much faster.
By default, a process is sent to a core that has the least load at that specific time. But Windows allows you to manually set the cores for the use of a process. Process Affinity is the ability to limit the execution of a process through a selected set of processor cores. For example, you can make Firefox use only first two cores of your octa-core processor. This can be used to avoid an application or process hogging up your system resources.
Setting process affinity using Task Manager
- Use the hotkey Ctrl+Shift+Esc to launch Task Manager.
- Switch to the Details tab.
- Right-click on a process the affinity of which you want to set and select Set affinity.
- Choose the CPU cores that are allowed for the execution of the selected process.
- Click on the OK button to set the affinity.
Setting process affinity using Process Explorer
- Download Process Explorer from https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer. Extract the downloaded ZIP to a folder.
- Launch Process Explorer and select any of the processes from the list for which you want to set the affinity. In the following screenshot, we have selected Firefox browser process “firefox.exe”.
- After selecting the process, select Process → Set Affinity from the menubar.
- In the windows that opens up, you can choose the number of cores that the selected process should be limited to. By default, all the available cores are selected – you can choose any one or more of these cores and click on the OK button.
Process affinity is not permanently set for an application or a process associated with it. It is set only for the currently active instance of a process. So if you set affinity for “firefox.exe” process using any of these methods and then the process ends, the affinity will be reset to use all the available CPU cores next time “firefox.exe” process is run.