11

I have read that setting something to realtime is a big no-no, so I am not going to do that. But I do have an application that I need to make sure always has the highest priority on my system as it is critical for the rest of the applications I am running. Is there any danger in setting the priority to high, which is one level below realtime?

Also, how would I be able to do this by changing the shortcut target? What is the command?

14
  • "Above normal" (windows 7) setting is safer. Some discussion here...stackoverflow.com/questions/1663993/…
    – Moab
    Sep 17, 2012 at 18:55
  • 1
    It's very dangerous. The major problem is priority inversion which results in the higher-priority process actually getting an effectively lower priority because it can be indefinitely blocked by a lower priority process. Sep 17, 2012 at 19:15
  • As mentioned "Realtime" is not necessarily bad so long as your process is well behaved and only runs when it needs and sleeps when it does not, otherwise it can (and will) prevent other tasks from running entirely.
    – Mokubai
    Sep 17, 2012 at 19:43
  • 2
    @David Schwartz, Cutler designed the Windows scheduler to avoid deadlock due to priority inversion. From support.microsoft.com/kb/96418, "The Windows NT scheduler solves this problem by randomly boosting the priority of threads that are ready to run (in this case the low priority lock-holders). The low priority threads run long enough to let go of their lock (exit the critical section), and the high- priority thread gets the lock back. If the low-priority thread doesn't get enough CPU time to free its lock the first time, it will get another chance on the next scheduling round ." Sep 17, 2012 at 20:46
  • @NicoleHamilton So that's why sometimes a program will open a few instances at once if it didn't open on the first click (and you clicked a few times), because of high load? Sep 17, 2012 at 22:11

4 Answers 4

8

Realtime isn't necessarily a "no-no". It just might starve other processes out of CPU cycles. Some applications can't handle that. Its something you would have to experiment with.

High should be less of a problem. However, you still need to monitor your system to see if all the applications are behaving well.

Here is how to change the process via command line, which you can put into a shortcut:

http://support.microsoft.com/kb/191771

4
  • 1
    On Windows, it does starve other processes very easily (including Task Manager itself).
    – user1686
    Sep 17, 2012 at 19:31
  • 3
    It all depends on your system. Depending on how CPU intensive the process it, a realtime affinity is fine. Im running a process in realtime right now with no issues. Also, it can help to set an affinity to one processor while setting the priority to realtime.
    – Keltari
    Sep 17, 2012 at 19:35
  • If a process is set to realtime, will it be given absolute priority over all other processes on the core it's running on? I've been trying to find ways to dedicate one of my cores to Dwarf Fortress while it's running.
    – SaintWacko
    Sep 17, 2012 at 20:22
  • Link is dead "Sorry, page not found"
    – sdbbs
    Mar 28 at 14:17
4

I would say it depends. If you only have one core/CPU on your computer, and it's a CPU-intensive task, I wouldn't set it to realtime. High might be okay, but that needs experimenting.

If you have multiple cores, and the process is single threaded: go ahead, set it however you want. Your other cores will still be free, even when one core is at 100% load the whole time.

If you have multiple cores and the process is multi threaded: it will depend if all threads will have 100% load. Some programs have a 'manager' thread that dispatches work to other threads but doesn't do a lot of processing itself. That would leave one core nearly free and thus allow for high or real-time priority.

Other programs will try to take in all cores. In this case high might be fine, but it needs experimenting.

Even others will only take a particular number of cores and might not use all cores available. In this case high or real-time priority should be fine.

Unless you're on a single core, go ahead, experiment. Most of the time it won't hurt to set it to high or even real-time. You can set the affinity of a process (how many cores it can use) in task manager as well. This way you can better balance the load on your CPU. It can also help keep temperatures and power consumption down, etc.

2
  • +1 Good point that a single-threaded app is no problem on a multi-core machine, no matter how compute-bound. Sep 17, 2012 at 22:11
  • Don't forget though, that as warned, [primarily] single threaded high priority processes - even if they affect only a single core - can hold global system synchronization locks for an abnormal amount of time.
    – dyasta
    Sep 18, 2012 at 15:45
2

Whether this will work for you depends entirely on what your application does. If it's grinding through a long, long computation that never needs to wait for i/o, expect that running that at high priority could bring your machine to its knees. But if the issue is latency and your application just needs to wake up really fast in response to an i/o completion or similar event, do a little quick processing and then go right back to sleep again, it will be fine.

1

In general, every application that sets its primary process priority to anything other than normal will adversely affect everything else on your machine in terms of performance. So if every application took this attitude of self-importance, eventually nothing would work properly.

The correct way to use higher priorities is in individually threaded TASKS, not in APPLICATIONS. And these tasks should either run only as needed and then stop or suspend themselves when they have no work to do. If when writing an application you feel you need to change a priority base level, then think very hard about how to make the interval where this is necessary as short as possible.

It may even be worth investing in a book or a course about concurrent and parallel processing before you go anywhere near something like priority hiking.

Not the answer you're looking for? Browse other questions tagged or ask your own question.