PowerShell – Change Base Priority of Process

email me

Base priority is the initial priority assigned to a task when it’s created. This priority can be “high”, “medium”, or “low”. Each engine has a run queue for each priority level, and there’s also a global run queue with a queue for each priority level.

When an engine is looking for a task to execute, it follows a specific order:

  1. It first checks its own high-priority run queue.
  2. If no tasks are found, it checks the high-priority global run queue.
  3. If still no tasks are found, it checks its own medium-priority run queue, and so on.

This process ensures that tasks in the high-priority run queues are scheduled onto engines more quickly than tasks in the medium or low-priority queues.

During execution, the Adaptive Server can temporarily elevate a task’s priority if necessary. However, it’s important to note that a task’s priority can never be lowered below its base priority.

When creating a user-defined execution class, you have the option to assign a base priority of high, medium, or low to the tasks within that class. This allows for greater control over task scheduling and execution.

Remember, the use of base priorities is a way to manage and optimize the execution of tasks, ensuring that higher priority tasks are executed first and system resources are used efficiently. It’s a fundamental concept in task scheduling and resource management in multi-tasking systems.

Each process belongs to one of the following priority classes:

  • IDLE_PRIORITY_CLASS
  • BELOW_NORMAL_PRIORITY_CLASS
  • NORMAL_PRIORITY_CLASS
  • ABOVE_NORMAL_PRIORITY_CLASS
  • HIGH_PRIORITY_CLASS
  • REALTIME_PRIORITY_CLASS

 

# MrNetTek 
# eddiejackson.net 
# 7/13/2024
# free for public use 
# free to claim as your own

# Get all Chrome processes
$chromeProcesses = Get-Process -Name chrome -ErrorAction SilentlyContinue

# Check if there are any Chrome processes running
if ($chromeProcesses) {
    foreach ($process in $chromeProcesses) {
        try {
            # Set the base priority to High
            $process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::High
            Write-Host "Set priority to High for process ID $($process.Id) ($($process.ProcessName))"
        } catch {
            Write-Host "Failed to set priority for process ID $($process.Id) ($($process.ProcessName)): $_"
        }
    }
} else {
    Write-Host "No Chrome processes found."
}

# Session Clean up
$chromeProcesses = ""
$process = ""

 


Notes

 

Base Priorities (Microsoft)