Processes - Set Affinity

Declaration

<AMPROCESSES ACTIVITY="setaffinity" PROCESSNAME="text" AFFINITY="text" />

Description: Sets the processor affinity of a given process. In Windows XP, Windows Vista, and Windows 7, 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 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.

Process Parameters

Property

Type

Required

Default

Markup

Description

Find by name

Text

No

(Empty)

  1. PROCESS="NOTEPAD.EXE"
  2. 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 tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: Set affinity of process "Photoshop.exe" to "1,3". If multiple instances of the process exist, apply changes to none.

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