VMware ESXi and vSphere Cluster Management
Set Process Affinity with Process Explorer
Learn how to use Process Explorer to restrict a Windows process to selected logical CPUs, evaluate the effects, and restore default scheduling eligibility.
Process affinity, also called processor affinity, is a scheduling restriction that limits the logical processors on which a process's threads may run. This guide shows how to set and remove that restriction with Process Explorer.
What process affinity means
A process is a running instance of a program. It can contain one or more threads, which are execution units that Windows schedules on processors.
Process affinity specifies the logical processors that are eligible to run every thread belonging to the selected process. If a process is allowed to use CPUs 2 and 3, Windows may schedule its threads on CPU 2 or CPU 3, but not on the other logical processors.
A logical processor is a processor scheduling unit presented to Windows. It may represent a physical CPU core or a hardware thread provided by simultaneous multithreading. For this reason, the CPU numbers in an affinity dialog do not necessarily correspond one-to-one with physical cores.
Affinity is an eligibility rule, not a reservation or performance guarantee. It does not guarantee that the process will continuously use one CPU, receive a fixed amount of CPU time, or run at a particular speed. The Windows scheduler still decides when eligible threads run and how much processor time they receive.
Windows default scheduling behavior
Without a restrictive affinity setting, a process is normally eligible to run on any logical processor available to it. The Windows scheduler assigns runnable threads to eligible logical processors and can move execution among those processors as needed.
This movement can help Windows balance work, respond to changing demand, and make use of available processor capacity. Setting affinity removes some of those choices for the selected process.
When setting affinity can help
- Workload partitioning: A background batch application can be limited to a subset of logical CPUs while other CPUs remain available for interactive applications.
- Controlled testing: A developer or troubleshooter can compare behavior when an application uses all logical CPUs with behavior when it uses a defined subset.
- Contention investigation: Restricting one workload can help test whether CPU competition contributes to latency or responsiveness problems.
- Throughput experiments: Affinity may improve throughput in some workload arrangements, but the result must be measured rather than assumed.
Throughput is the amount of work completed during a period of time. A change that lowers CPU contention might improve throughput, but limiting a process can also reduce its available parallelism.
Set process affinity in Process Explorer
- Open Process Explorer, the Windows process-inspection and management utility.
- Locate the target application or process in the main process list.
- Right-click the target process.
- Choose Set Affinity from the context menu.
- In the affinity dialog, select the logical CPU checkboxes on which the process is allowed to run. Clear the checkboxes for CPUs that should not be eligible.
- Click OK to apply the selection.
Example: restrict a process to CPUs 2 and 3
Suppose the system exposes CPUs 0 through 7 and you want a batch application to use only CPUs 2 and 3:
- Find the batch application's process in Process Explorer.
- Right-click it and choose Set Affinity.
- Clear CPUs 0, 1, 4, 5, 6, and 7.
- Leave CPUs 2 and 3 selected.
- Click OK.
The process and all of its threads are then restricted to CPUs 2 and 3. CPUs 0, 1, 4, 5, 6, and 7 are unavailable to that process, although unrelated processes can still use them.
Understanding affinity selections
For example, selecting CPUs 2 and 3 does not assign a fixed percentage of CPU time to the process. It only defines where its threads are permitted to run.
Effect and scope of the change
Affinity applies to the selected process and its threads. It does not automatically configure unrelated processes, services, or applications.
Restricting the eligible CPU set can reduce the process's maximum parallel execution capacity. A multithreaded program that could previously use eight logical processors may be limited to two. Whether that is beneficial depends on the workload, processor topology, contention, and other system resources.
Affinity also does not replace process priority. Priority influences scheduling preference, while affinity limits the processors on which the process may run. These settings have different effects and should not be treated as interchangeable.
Cautions and operational considerations
- Do not restrict a CPU-intensive process to too few logical processors without a specific reason.
- A restrictive setting can worsen performance, responsiveness, or throughput if the workload needs more CPU capacity.
- Test under representative conditions, including realistic input sizes, concurrency, and background activity.
- Measure completion time, throughput, CPU utilization, latency, and responsiveness before and after the change.
- If the result is not beneficial, restore all available logical CPUs.
- Changing another process's settings may require sufficient permissions, especially for elevated, system-owned, or otherwise protected processes.
Revert the affinity setting
- In Process Explorer, locate the same process.
- Right-click it and choose Set Affinity.
- Select every available logical CPU checkbox.
- Click OK.
With all available logical CPUs enabled, the process returns to broad scheduling eligibility. This restores default-style behavior for the affinity setting, although it does not change other settings such as priority.
Troubleshooting
The application becomes slower
The process may have been limited to too few logical processors for its thread count or workload. Expand the selected CPU set or restore all CPUs, then compare performance using the same workload.
The Set Affinity action cannot be applied
Your account may lack permission to alter the process, or the process may be elevated, system-owned, or protected. When authorized, run Process Explorer with appropriate administrative privileges. Otherwise, test with a process that your account is permitted to manage.
Overall responsiveness does not improve
The bottleneck may not be CPU placement. Disk, memory, network activity, lock contention, or another resource may be responsible. Measure CPU and other resource usage, compare runs with and without affinity, and investigate the resource that is actually limiting the workload.
CPU numbers do not match expected physical cores
Process Explorer displays logical processors, which can include hardware threads. Interpret the affinity selection in logical-CPU terms. If physical-core placement matters, inspect the system's processor topology before drawing conclusions.
Practical investigation method
- Record baseline performance with all logical CPUs enabled.
- Choose a clearly defined CPU subset and document the selection.
- Run the same representative workload.
- Compare throughput, completion time, CPU usage, and responsiveness.
- Repeat the test when possible to reduce the effect of unrelated system activity.
- Keep the restriction only if measurements show a meaningful benefit; otherwise restore all CPUs.
For related guidance, see Set Process Affinity.