Plugin process.spf

File: process.spf
Author: Nicholas Nemtsev
Description: Assigning a specified priority to a process; tracing the moment when the process stops to load the CPU.

New words:


S" process-name" <priority-class> PRIORITY

Assigns to a process a specified priority from the list of priority classes .

Examples:

S" plugger.exe" HIGH_PRIORITY_CLASS PRIORITY
S" test.exe" IDLE_PRIORITY_CLASS PRIORITY

S" process-name" <interval-sec> <min-usage> <max-count> PROC-WAIT-CPU-USAGE

This postfix word pauses the execution of the task until the specified process stops to load the CPU. When the percentage of time that a process used the CPU becomes lower, than specified in PROC-WAIT-CPU-USAGE arguments, the task execution is resumed.

There is a description of PROC-WAIT-CPU-USAGE arguments:

Let's examine the following code::

S" calculator.exe" 10 20 5 PROC-WAIT-CPU-USAGE

Explanation: pause the task and monitor the calculator.exe CPU time usage for every 10 seconds. Resume the task when the percentage of time that a process used the CPU becomes lower than 20% five time in a row.

Example:

#( test_proc-wait-cpu-usage
WatchHotKey: "^@r"
Action:
    START-APP: d:\tools\robosoft\robosoft.exe
    S" robosoft.exe" 2 1 3 PROC-WAIT-CPU-USAGE
    BEEP: 500 500
    \ ...
)#

This word only works in WinNT/2000/XP.


S" process-name" <affinity-mask> AFFINITY

Allows to specify the affinity for a given process (set the processor on which the process are allowed to run). <affinity-mask> is a integer in which each bit represents the processor on which the process are allowed to run. When you set <affinity-mask> to 0, operating systrm scheduling algorithms set the process affinity.

Decimal value Binary bit mask Processor in use
1 00000001 0
3 00000011 0 1
7 00000111 0, 1 2
8 00001000 3
15 00001111 0, 1, 2 3
31 00011111 0, 1, 2, 3 4
63 00111111 0, 1, 2, 3, 4 5
127 01111111 0, 1, 2, 3, 4, 5 6

:

S" plugger.exe" 0 AFFINITY
S" test.exe" 3 AFFINITY