views:

2578

answers:

3

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 never to realtime. Could anyone clear up what the realtime process priority setting does as opposed to High, and Above Normal?

+4  A: 

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.

Michael Burr
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
+6  A: 

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
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.
+4  A: 

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

Larry Osterman