77

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'.

What does the 'Realtime' process priority setting do, compared to 'High', and 'Above Normal'?The process priority list, ranging from Low to Realtime.

Zelo101
  • 70
  • 1
  • 6
Chris S
  • 62,476
  • 49
  • 214
  • 238

7 Answers7

82

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.

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

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.

JinSnow
  • 1,171
  • 4
  • 23
  • 45
  • 4
    Could it be dangerous to the system to put a single random process (such as a video game) on realtime priority? Would high priority be recommended/would there be a noticeable performance drop for that application? – mrfred Apr 08 '15 at 21:05
  • 21
    @mrfred I wouldn't say it's dangerous, just that it slows down the entire system if it is a large program. Try setting Minecraft's priority to Realtime. Trust me, it's fun. Your mouse slows down, the keys take 5 seconds to respond, and explorer.exe becomes unresponsive! – AMDG Jul 08 '15 at 01:36
  • 3
    @mrfred I personally have run skyrim on high and realtime priority for months at a time, and it's made the game run far far smoother, with only the occasional audio artefact (for whatever reason). I've never suffered any problems from doing this... I assume that the system would at least overheat if something was going horribly wrong, but of course, I don't really know what COULD go wrong. Perhaps having multiple cores counters any starvation of resources to IO devices etc.. – Totem Jun 28 '16 at 17:00
  • There is a difference between a real-time priority *thread* and the real-time base priority class. The latter applies to the entire process and without additional setting of individual thread priorities, won't cause any threads to be real-time. – dyasta Nov 26 '20 at 13:43
26

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 SeIncreaseBasePriorityPrivilege to put a thread into the Real Time class.

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.

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

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.

Doc Brown
  • 18,656
  • 6
  • 48
  • 86
Michael Burr
  • 311,791
  • 49
  • 497
  • 724
  • 8
    Yes, realtime threads are appropriate if you have a thread that doesn't have much to do but *needs* to experience good response times. – Artelius Nov 02 '09 at 23:31
  • Iknow I know it's an old post but I found that book chapter really nice... got me going! https://www.google.ca/search?q=C04X1116607.pdf&ie=utf-8&oe=utf-8&gws_rd=cr&ei=cSTqVJzQNvHnsATun4CIDA#q=X1116607.pdf – MotherDawg Feb 22 '15 at 19:15
  • 1
    I found a link to the book chapter thanks to Archive.org's Wayback Machine: http://web.archive.org/web/20140909124652/http://download.microsoft.com/download/5/b/3/5b38800c-ba6e-4023-9078-6e9ce2383e65/C06X1116607.pdf (btw, I highly recommend making a custom search engine in Chrome like this: https://i.imgur.com/0kNVAi0.png). Then you just type wayback and paste the same url you're on. You may have to remove the http:// prefix. – Brent Rittenhouse Oct 22 '18 at 07:20
16

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 :)

Eric Petroelje
  • 57,359
  • 8
  • 118
  • 174
  • Agreed. It's important to know what it means (utmost priority is given to that thread, above all else), but if you ever find yourself asking if you should use it, you definitely should not. – Daniel T. Nov 02 '09 at 22:27
  • 6
    how are you going to learn to use it if you don't ask how to use it? I guess you can use it and see what happens then you'll learn but I feel your discouraging learning – fifamaniac04 Jun 09 '15 at 17:36
2

Real-time is the highest priority class available 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 class raises 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.

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 not a real-time OS. It works, for the most part, though is not perfect since the OS isn't designed for real-time operations.

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.

Matt
  • 70,063
  • 26
  • 142
  • 172
dyasta
  • 1,889
  • 15
  • 23
1

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

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

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.

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.

Uwe Keim
  • 36,867
  • 50
  • 163
  • 268
wizkid18
  • 11
  • 1
  • 2
    You're right that changing the process priority class does not affect CPU utilization, so long as there is not contention for the CPU. BUT, you're wrong in thinking that Windows caps max process priorities based on CPU utilization. Instead, a security privilege protects against setting 'real time' to prevent haphazard use. – dyasta Aug 15 '14 at 20:31
  • 1
    (reading years later) - The problem here is that threads can't be divided. So, you may have 8 cores, but only 2 CPU bound (100% active) threads. Thus you say "Why aren't my other 6 cores used?". Or, in your case, "Why isn't my last core used?". The remaining cores will appear to do nothing. And that is how you want it. If the thread were swapped around from core to core it would decrease performance. App developer has to multi-thread and not everything can be multi-threaded. – dyasta Sep 21 '17 at 14:40
0

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.

0

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.

mylogon
  • 2,283
  • 2
  • 24
  • 39