Process priority in Windows 7. Managing process priorities in Windows. Changing priority values

7 answers

A real-time priority thread can never be prevented by timer interrupts and runs at a higher priority than any other thread on the system. Because such CPU-bound real-time priority thread can completely destroy the machine.

Creating real-time priority threads requires a privilege (SeIncreaseBasePriorityPrivilege), so it can only be done by an administrator.

For Vista and beyond, one option for applications that require them to run in real-time priority is to use the Multimedia Class Scheduler Service (MMCSS) and let it manage the priority of your threads. MMCSS will prevent your application from using too much CPU time, so you don't have to worry about tanking the machine.

It's just that the "Real Time" priority class is higher than the "High" priority class. I don't think there's much more there. Oh yes, you must have SeIncreaseBasePriorityPrivilege to put the thread in the Real Time class.

Windows sometimes increases the priority of a thread for various reasons, but will not increase the priority of a thread in a different priority class. It also will not increase the priority of threads in the real-time priority class. Thus, a thread with a high priority will not receive any automatic temporary promotion to the real-time priority class.

Russinovich's "Inside Windows" chapter on how Windows handles priorities is a great resource for learning how it works:

Note that there are absolutely no problems with a thread having real-time priority on a normal Windows system - they are not necessary for special processes running on dedicatd machines. I believe that media drivers and/or processes may require real-time priority threads. However, such a thread should not require a lot of CPU - it should block most of the time so that normal system events can be processed.

This will be the highest priority setting available and will typically only be used in the field intended to run that specific program. It's actually high enough that it can starve keyboard and mouse threads to the point where they become unresponsive.

So, if you have to ask, don't use it :)

In real time, this is the highest priority class available to the process. Therefore, it differs from "High" in that it is one step larger, and "Above Normal" in that it is two steps larger.

Similarly, in real time there is also a thread priority level.

A process's priority class raises or lowers all the effective priorities of threads in a process and is therefore considered the "base priority".

So the process has:

  • Base Process Priority Class.
  • Individual thread priorities, offsets of the base priority class.

Since real-time applications are supposed to be backed up and absolutely must pre-empt other running processes, there is a special security privilege to protect against accidental use of it. This is determined by the security policy.

On NT6+ (Vista+), using the Vista Media Class Scheduler is the correct way to achieve real-time operations on what is not a live OS. It works, for the most part, although it's not perfect since the OS isn't designed for real-time operations.

Microsoft considers this priority very dangerous, and rightly so. No application should use it except in special circumstances, and even then try to limit its use to temporary needs.

Once Windows knows that a program is using a higher priority, it seems to limit the priority of the process.

Setting the priority from IDLE to REALTIME does NOT change CPU usage.

I found on my AMD multi-processor that if I drop one of the CPUs as LAST, the CPU usage will be MAX OUT and the last CPU will remain idle. CPU speed increases up to 75% on my Quad AMD.

Use Task Manager -> select process->Right click process->Select->Set affinity Click all except last processor. CPU usage will increase to MAX on remaining processors and frame count if video processing increases.

We use a dictionary. If programs are not closed, they use our computer's resource. You can see what is actually happening in a special Windows OS program. But not just look, but manage the distribution of resources in order to improve performance. Let's look at how to increase priority in the Windows Task Manager.

When working with many programs, the computer switches from one to another in a certain order. The ones he deems most important are executed first. The degree of importance is called priority. Typically, it is controlled by the program code itself. But the user can change the basic parameter to some other one, thereby making what is important to him at the moment faster.

Queue types

The degree of importance has the following gradations:

  • Real-time priority means that all computer resources are given to the selected process, even those resources that were intended for system processes, think before you boost it to that extent.
  • high;
  • above average;
  • ordinary;
  • below the average;
  • short.

Changing priority values

Let's look at how to set priority in the Task Manager:


IMPORTANT. Remember that high values ​​for one program can significantly reduce the performance of the machine as a whole. Increase gradually, and through experience, find the degree that will make the work comfortable.

When does this apply? Mainly for solving temporary tasks. For example, you are watching a movie and at the same time downloading some data from the Internet, and the video is periodically interrupted. Increasing the importance of the player will solve this problem. This is also often used to improve browser performance when browsing the Internet.

As already mentioned, the change is valid only for a certain point in time while the program is running. When it restarts it will be back to the base values. Let's look at how to change the priority of Windows tasks in the most convenient way possible.

Other ways to work with performance

Agree, experimenting with the settings every time is very inconvenient. There are special programs that can simplify the procedure. For example, Process Explorer and Mz CPU Accelerator. We will not dwell on them in detail; we will only note the essence of their work.

Mz CPU Accelerator allows you to automatically increase the values ​​for the active window program, doing it very efficiently. In addition, it allows you to control the allocation of processor resources, for example, to allocate one or two cores to a program instead of all. In general, the program allows you to increase the speed of applications.

Process Explorer allows you to get detailed information about all processes occurring on your computer and set more advanced settings than the standard Windows tool.

Thus, knowing how to change the priority level in the Task Manager, you can increase the speed of your computer and avoid errors and freezes. If you have tips on how to change this setting in a particular situation when working in Windows, share them with other users by leaving a comment below.

Answer from Null[guru]
First one command of one process is executed, then another, then the second command of the first process, and so on. The priority of a process indicates how often the processor accesses it, that is, the higher the priority, the higher the speed of the program, but this slows down the work of other processes.


Answer from Enlightenment[active]
Immediately after the context switch, the kernel starts the process scheduling algorithm, selecting for execution the process with the highest priority among the processes that are in the “reserve” and “ready to execute, loaded into memory” states. It makes no sense to consider processes that are not loaded into memory, since without being loaded, the process cannot execute. If several processes have the highest priority, the kernel, using the principle of a circular list (carousel), selects among them the process that has been in the “ready to execute” state longer than the others. In general, whichever program you are accessing has priority, but along with it there are also other processes that must participate with it, hence the priority. . real time means every second.

Instructions

Press the key combination “Ctrl+Alt+Delete”. A list of actions that can be performed will appear on the screen.

In the task manager window that opens, go to the “Applications” tab.

Select the program whose priority you want to change. Right-click on it and, in the drop-down menu, click on “Go to processes”. All programs that run on a computer have their own processes, and it is for them that priorities are set.

In the drop-down menu, set the priority to medium, high, low or other.

Helpful advice

You can view more information about the running process in the Task Manager. To do this, right-click on it and select the “Properties” command. The dialog box that appears displays details about the process, including its location and size. Click the Details tab to view detailed information about the process.

The task manager can be launched by right-clicking on the taskbar and selecting “Task Manager” from the drop-down menu.

Sources:

  • how to change your priorities

Process scheduling in UNIX is based on priority. Typically each process has two priority attributes. There are 32 priority levels in Windows. On your computer, you can speed up the work of programs that are in the operating system. To do this, you just need to increase the priority of the process.

Instructions

You need to go to the "Task Manager". To do this, right-click on the “Taskbar” section. Select "Task Manager" from the context menu. Go to the “Processes” tab. There you will see a list of all running processes. Find the one you want and right-click on it. Next, select the “Priority” command. Now you can increase the priority of the process. "Task Manager" is possible.

You can also increase the priority using the InqSoft Speedballs utility. This monitors all processes. Launch it. Increasing process priority automatically. By going to Settings, you can change the settings. In the menu where it says “Increase priority to,” check the High box and click “Apply.”

In the Control Panel, go to the Settings section. Select Performance and Maintenance. Go to the System menu and switch to the Performance tab. Find the Application Performance section and use the arrow to set the desired process priority level.

You can increase the priority of a process in Linux as well. This is done through the console. Press the top command - text will appear in front of you. Now you can perform different actions. To increase the priority, press the r key on the keyboard.

If you need to increase the priority of a process in a game, do the following. For example, take the game World of Warcraft. Open through “Start”, then the “Notepad” program. Paste the following text: @echo off cd /d "C:/Program Files/World of Warcraft"start/high wow.exe. Change this path: "C:/Program Files/World of Warcraft" to the new one that you will have. Save the previously written text in Notepad in .bat format. Launch your game through this file. You will notice an increase in priority.

Sources:

  • how to change priority

No matter how powerful the reserve of resources your computer has, they are still not endless. A special OS component distributes RAM and graphics memory, priority and frequency of access to the processor, cache memory and some other resources between all running system and application programs. He does this in accordance with the priority table, which he himself compiles by default. The user has the opportunity to intervene in the distribution of the degree of importance of running processes.

Instructions

Launch Windows Task Manager. This can be done in several ways - for example, by pressing the key combination Ctrl + Alt + Delete. In Windows 7, an additional menu appears on the screen in which you should select “Launch Task Manager”, but in earlier versions of Windows this intermediate step is not present. Another way to open the task manager is to open the program launch window by pressing the Win + R key combination, then entering the taskmgr command and clicking OK.

Right-click on the line with the desired process and expand the “Priority” section in the context menu. By default, all processes have "normal" priority - change this by selecting any of the six options listed. However, do not forget that in some cases, excessively increasing the priority of application programs (the “High” and “Real Time” items) can lead to a sluggish response of the operating system to keystrokes, mouse movements, etc. The same problem can also occur if the priority of system processes (for example, a process named explorer) is excessively lowered.

By definition, Windows is a multitasking operating system. That is, several tasks can be performed in it simultaneously. However, the task is different. And the difference lies in priority. That is, when executing a program, Windows distributes resources in a certain way, depending on the priority of which process (program). In the future I will call programs processes, it’s easier. Every running program in Windows is a process. Priorities are different - big, small, but more on that later. How can this help us? Here's what. Many people complain about the slow execution of Vb programs. At one time I came across this with the most obvious example. Imagine a program that must perform some action at a certain time interval - for example, display something to the user. Simple, you say. Take a timer and go ahead. What if, in addition to this, the program must periodically count something else, and more than once, and there are many timers? It will slow down. And not Windows, but only the program. Not fair? Yes. This means that Windows allocates few resources to your program, which are clearly not enough for it. So ask Windows for more, but how?

Like this

So we need to change the priority. It's time to talk about them. In Windows "98 there are fewer priorities than in Windows Me or 2000, but they still exist. Here they are.

Real time priority - the program runs as if it alone were the purpose of Windows. All resources are given to her.

High priority (high) - the program is executed in such a way as to leave a little time for other applications.

Normal - execution proceeds in the usual way.

Low (idle) - if execution occurs, it is only when Windows has nothing to do.

Well, the running program first receives Normal priority and runs as usual. With this priority, no matter what the program does, it will not be able to consume so many resources that Windows will hang. In theory. But that doesn't suit us. We need high priority or, if everything is very stressful, real time. But real time is a dangerous thing. Even a mouse can easily slow down. And I don’t want to talk about the rest of the programs. Just a bastard and that's all. So, how can you change the priority?

API again

Yes, the SetPriorityClass function is responsible for setting the priority. That is, by calling it and passing everything it needs, we will receive the desired priority.

Private Declare Function SetPriorityClass _ Lib "kernel32" (ByVal hProcess As Long, _ ByVal dwPriorityClass As Long) As Long

  • hProcess is the Handle of the process. About him below.
  • dwPriorityClass - priority. That's what we need.

Priority constants:

Private Const REALTIME_PRIORITY_CLASS = &H100 Private Const HIGH_PRIORITY_CLASS = &H80 Private Const NORMAL_PRIORITY_CLASS = &H20 Private Const IDLE_PRIORITY_CLASS = &H40

It's simple - take the constant and go ahead, but we need to get the Handle of the process. That is, process and window for Windows are almost synonymous things, but not always. Window Handle is one thing, Process Handle is completely different. That is, a process can have many windows, but a window has only one process owner. This means that we need to learn how to find the Handle of the process itself. The OpenProcess function will help us with this; after passing parameters to it, it will tell us what Handle the process has.

Private Declare Function OpenProcess _ Lib "kernel32" (ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

dwDesiredAccess - what we want to know (the Handle of a process is different, to end the process - one, to receive information - another). We will use the PROCESS_QUERY_INFORMATION constant, that is, query the process.

Private Const PROCESS_QUERY_INFORMATION = &H400

bInheritHandle is a Boolean variable. If you pass it True, then the resulting Handle can be used by another process in the future. But we don't need that. We pass False there.

DwProcessId - yes, and this is another thing - the identifier (id) of the process. We need to get it too. How? Just! The GetCurrentProcessId function, called without parameters (thank God), simply returns the id of the current process.

Private Declare Function GetCurrentProcessId _ Lib "kernel32" Alias ​​"GetCurrentProcessId" () As Long

All. You can breathe and do everything beautifully.

Some code

Option Explicit Private Declare Function SetPriorityClass _ Lib "kernel32" (ByVal hProcess As Long, _ ByVal dwPriorityClass As Long) As Long Private Const REALTIME_PRIORITY_CLASS = &H100 Private Const HIGH_PRIORITY_CLASS = &H80 Private Const NORMAL_PRIORITY_CLASS = &H20 Private Const IDLE_PRIORITY _CLASS = &H40 Private Declare Function OpenProcess _ Lib "kernel32" (ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Const PROCESS_QUERY_INFORMATION = &H400 Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long Private Sub SetPriority(Priority As Long) Dim ProcId As Long "variable for process id Dim ProcHandle As Long "variable for process handle ProcId = GetCurrentProcessId "get id ProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcId) "received Handle Call SetPriorityClass(ProcHandle, Priority) " set priority End Sub Private Sub Form_Load () "set the priority SetPriority HIGH_PRIORITY_CLASS End Sub