%SET_PRIORITY_CLASS

Set the priority class for a process

WSupported on Windows

 

 

NSupported in Synergy .NET
status = %SET_PRIORITY_CLASS(class)

Return value

status

One of the following values: (n)

1 = Successful

0 = Not successful

Arguments

class

The priority class for the process: (i)

D_ABOVE_NORMAL_PRIORITY_CLASS

Process that has priority above normal-priority but below high-priority class processes.

D_BELOW_NORMAL_PRIORITY_CLASS

Process that has priority above idle-priority but below normal-priority class processes.

D_HIGH_PRIORITY_CLASS

Process that performs time-critical tasks that must be executed immediately. The threads of the process preempt the threads of normal- or idle-priority class processes. An example is the Task List, which must respond quickly when called by the user, regardless of the load on the operating system. Use extreme care when using the high-priority class, because a high-priority class application can use nearly all available CPU time.

D_IDLE_PRIORITY_CLASS

Process whose threads run only when the system is idle. The threads of the process are preempted by the threads of any process running in a higher priority class. An example is a screen saver. The idle-priority class is inherited by child processes.

D_NORMAL_PRIORITY_CLASS

Process with no special scheduling needs.

D_BACKGROUND_BEGIN

Begin background processing mode. The system lowers the resource scheduling priorities of the process (and its threads) so it can perform background work without significantly affecting activity in the foreground. The function fails if the process is already in background processing mode.

D_BACKGROUND_END

End background processing mode. The system restores the resource scheduling priorities of the process (and its threads) as they were before the process entered background processing mode. The function fails if the process is not in background processing mode.

Discussion

Raising the priority can only be performed by a member of the administrator group who has elevated privileges, so you should use the dbrpriv or dbspriv runtime and ensure that the user specified in the task scheduler can elevate to do this. Scheduled tasks are run under the administrator account by default.

The D_XXX_PRIORITY_CLASS values affect the CPU scheduling priority of the process. For processes that perform background work such as file I/O, network I/O, or data processing, it is not sufficient to adjust the CPU scheduling priority; even an idle CPU priority process can easily interfere with system responsiveness when it uses the disk and memory.

Processes that perform background work should use the D_BACKGROUND_BEGIN and D_BACKGROUND_END values to adjust their resource scheduling priorities. Processes that interact with the user should not use D_BACKGROUND_BEGIN.

If %SET_PRIORITY_CLASS is not successful, you can get extended error information by calling %SYSERR.