Processes - Set affinity

Declaration

<AMPROCESSES ACTIVITY="setaffinity" PROCESSNAME="text" SAMEPROCESS="text (options)" PROCESSID="text" AFFINITY="text" />

Related Topics   

Description

Sets the processor affinity of a given process. In Windows 10, applications run on all available cores of the processor by default. If you have a dual or quad core processor, then you can set affinity to an application to control which core of the processor an application can use. This gives you better control over processors when applications place demands on system resources.

NOTE: The process affinity setting lasts as long as an application is open. When you close the application or restart the computer, the affinity returns to the default settings. Also, It is recommended not to change the process affinity for system processes.

Practical usage

On a multi-CPU server, you can configure application pools to establish affinity between worker processes and CPUs in order to take advantage of more frequent CPU cache hits. You can assign one application or program to use only one processor while other applications run on other processors.

Parameters

Process

Property Type Required Default Markup Description
Find by name Text No (Empty)
  • PROCESS="NOTEPAD.EXE"
  • PROCESS="C:\folder\process.exe"
If enabled, specifies the name of the process in which to set. This parameter supports entry of the absolute path (C:\folder\process.exe) or relative path (Notepad.exe) of the process. If this parameter is enabled, the Find by process ID parameter becomes inactive. This parameter is enabled by default.
If multiple instances of the process exist, apply changes to Text (options) No Oldest SAMEPROCESS="nothing" Indicates which process instance should be set in case more than one instance of a given process is running. The available options are:
  • Oldest (default) - Only the oldest running instance of the process will have its priority set.
  • Newest - Only the newest (last) running instance of the process will have its priority set.
  • None - No instance of the process will have its priority set.
  • All - All instances of the process will have its priority set.
Find by process ID Text No Yes PROCESSID="11452" If enabled, specifies the process ID of the process to set. If this parameter is enabled, the Find by name  parameter becomes inactive. This parameter is disabled by default.
NOTE: Use the Processes - Get Information activity to retrieve the process ID of a given process.
Change process affinity to (comma-delimited list of CPU identifiers) Text Yes (Empty) AFFINITY="1,2" The comma delimited list of CPU identifiers (unique IDs) of the processors in which to set process affinity. For example, to utilize processors 1, 2 and 3, enter "1,2,3".

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This sample task sets the affinity of the Photoshop.exe process.

Copy
<AMPROCESSES ACTIVITY="setaffinity" PROCESSNAME="Photoshop.exe" SAMEPROCESS="nothing" AFFINITY="1,3" />