windows 什么是“实时”进程优先级设置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1663993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:52:27  来源:igfitidea点击:

What is the 'realtime' process priority setting for?

windowstasktaskmanagerthread-prioritytask-management

提问by Chris S

From what I've read in the past, you're encouraged not to change the priority of your Windows applications programmatically, and if you do, you should never change them to 'Realtime'.

从我过去读到的内容来看,我们鼓励您不要以编程方式更改 Windows 应用程序的优先级,如果您这样做了,则永远不要将它们更改为“实时”。

What does the 'Realtime' process priority setting do, compared to 'High', and 'Above Normal'?enter image description hereenter image description here

与“高”和“高于正常”相比,“实时”进程优先级设置有何作用?在此处输入图片说明在此处输入图片说明

回答by ReinstateMonica Larry Osterman

A realtime priority thread can never be pre-empted by timer interrupts and runs at a higher priority than any other thread in the system. As such a CPU bound realtime priority thread can totally ruin a machine.

实时优先级线程永远不会被定时器中断抢占,并以比系统中任何其他线程更高的优先级运行。因此,受 CPU 限制的实时优先级线程可以完全毁掉一台机器。

Creating realtime priority threads requires a privilege (SeIncreaseBasePriorityPrivilege) so it can only be done by administrative users.

创建实时优先级线程需要特权 ( SeIncreaseBasePriorityPrivilege),因此只能由管理用户完成。

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

对于 Vista 及更高版本,确实需要以实时优先级运行的应用程序的一种选择是使用多媒体类调度程序服务(MMCSS) 并让它管理您的线程优先级。MMCSS 将防止您的应用程序使用过多的 CPU 时间,因此您不必担心机器停运。

回答by Michael Burr

Simply, the "Real Time" priority class is higher than "High" priority class. I don't think there's much more to it than that. Oh yeah - you have to have the SeIncreaseBasePriorityPrivilegeto put a thread into the Real Time class.

简单地说,“实时”优先级高于“高”优先级。我认为没有比这更多的了。哦,是的 - 您必须SeIncreaseBasePriorityPrivilege将线程放入实时类。

Windows will sometimes boost the priority of a thread for various reasons, but it won't boost the priority of a thread into another priority class. It also won't boost the priority of threads in the real-time priority class. So a High priority thread won't get any automatic temporary boost into the Real Time priority class.

Windows 有时会出于各种原因提高线程的优先级,但不会将线程的优先级提高到另一个优先级类。它也不会提高实时优先级类中线程的优先级。因此,高优先级线程不会自动临时提升到实时优先级类中。

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

Russinovich 关于 Windows 如何处理优先级的“Inside Windows”一章是了解其工作原理的重要资源:

Note that there's absolutely no problem with a thread having a Real-time priority on a normal Windows system - they aren't necessarily for special processes running on dedicatd machines. I imagine that multimedia drivers and/or processes might need threads with a real-time priority. However, such a thread should not require much CPU - it should be blocking most of the time in order for normal system events to get processing.

请注意,在普通 Windows 系统上具有实时优先级的线程绝对没有问题——它们不一定适用于在专用机器上运行的特殊进程。我想多媒体驱动程序和/或进程可能需要具有实时优先级的线程。但是,这样的线程不应该需要太多 CPU - 它应该在大部分时间处于阻塞状态,以便正常的系统事件得到处理。

回答by Eric Petroelje

It would be the highest available priority setting, and would usually only be used on box that was dedicated to running that specific program. It's actually high enough that it could cause starvation of the keyboard and mouse threads to the extent that they become unresponsive.

这将是可用的最高优先级设置,并且通常仅用于专用于运行该特定程序的机器。它实际上足够高,可能会导致键盘和鼠标线程饥饿,以至于它们变得无响应。

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

所以基本上,如果你不得不问,不要使用它:)

回答by dyasta

Real-time is the highest priority classavailable to a process. Therefore, it is different from 'High' in that it's one step greater, and 'Above Normal' in that it's two steps greater.

实时是进程可用的最高优先。因此,它与“高”的不同之处在于它大了一步,而“高于正常”则是大了两步。

Similarly, real-time is also a thread priority level.

同样,实时也是一个线程优先级。

The process priority classraises or lowers all effective thread priorities in the process and is therefore considered the 'base priority'.

进程优先级提高或降低进程中所有有效的线程优先级,因此被视为“基本优先级”。

So, a process has a:

所以,一个进程有一个:

  1. Base process priority class.
  2. Individual thread priorities, offsets of the base priority class.
  1. 基本进程优先级类
  2. 单个线程优先级,基本优先级类的偏移量。

Since real-time is supposed to be reserved for applications that absolutely must pre-empt other running processes, there is a special security privilege to protect against haphazard use of it. This is defined by the security policy.

由于应该为绝对必须抢占其他正在运行的进程的应用程序保留实时,因此有一个特殊的安全特权来防止对其进行随意使用。这是由安全策略定义的。

In NT6+ (Vista+), use of the Vista Multimedia Class Scheduler is the proper way to achieve real-time operations in what is nota real-time OS. It works, for the most part, though is not perfect since the OS isn't designed for real-time operations.

在NT6 +(Vista的+),使用Vista的多媒体类调度的是什么,是实现实时操作的正确方法不是一个实时操作系统。它在大多数情况下有效,但并不完美,因为操作系统不是为实时操作而设计的。

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

Microsoft 认为此优先级非常危险,这是正确的。除非在非常特殊的情况下,否则任何应用程序都不应使用它,即使如此,也应尝试将其使用限制为临时需要。

回答by wizkid18

Once Windows learns a program uses higher than normal priority it seems like it limits the priority on the process.

一旦 Windows 得知程序使用高于正常的优先级,它似乎限制了进程的优先级。

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

将优先级从 IDLE 设置为 REALTIME 不会改变 CPU 使用率。

I found on My multi-processor AMD CPU that if I drop one of the CPUs ot like the LAST one the CPU usage will MAX OUT and the last CPU remains idle. The processor speed increases to 75% on my Quad AMD.

我在我的多处理器 AMD CPU 上发现,如果我像最后一个那样丢弃其中一个 CPU,CPU 使用率将达到 MAX OUT,而最后一个 CPU 保持空闲。在我的 Quad AMD 上,处理器速度提高到 75%。

Use Task Manager->select process->Right Click on the process->Select->Set Affinity Click all but the last processor. The CPU usage will increase to the MAX on the remaining processors and Frame counts if processing video will increase.

使用任务管理器->选择进程->右键单击进程->选择->设置亲和性单击除最后一个处理器之外的所有处理器。如果处理视频增加,剩余处理器和帧数的 CPU 使用率将增加到 MAX。

回答by Cheaty Hotbeef

It basically is higher/greater in everything else. A keyboard is less of a priority than the real time process. This means the process will be taken into account faster then keyboard and if it can't handle that, then your keyboard is slowed.

它基本上在其他所有方面都更高/更大。键盘的优先级低于实时进程。这意味着该过程将比键盘更快地被考虑在内,如果它无法处理,那么您的键盘就会变慢。

回答by Sam Hook

Like all other answers before real time gives that program the utmost priority class. Nothing is processed until that program has been processed.
On my pentium 4 machine I set minecraft to real time a lot since it increases the game performance a lot, and the system seems completely stable. so realtime isn't as bad as it seems, just if you have a multi-core set a program's affinity to a specific core or cores (just not all of them, just to let everything else be able to run in case the real time set programs gets hung up) and set the priority to real time.

像实时之前的所有其他答案一样,该程序具有最高优先级。在处理完该程序之前,不会处理任何内容。
在我的奔腾 4 机器上,我将 Minecraft 设置为实时很多,因为它大大提高了游戏性能,并且系统似乎完全稳定。所以实时性并不像看起来那么糟糕,只要你有一个多核,将程序的亲和力设置为一个或多个特定核心(不是全部,只是为了让其他一切都能够运行,以防实时设置程序被挂断)并将优先级设置为实时。