Jump to content
  • Advertisement
Sign in to follow this  
KontosHarry

Set priority

This topic is 3674 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Are you referring to the process' scheduling priority? If so, it's architecture-specific... which OS are you targeting? BTW, changing a program's priority usually has very little effect on its performance... what are you using it for?

Share this post


Link to post
Share on other sites
"I just bought a Ferrari; how do I convince the local law enforcement to let me drive faster?"

Process priority is a concept belonging to the operating system. You will need to do something specific depending on which OS you have, and you might not necessarily be allowed to do it from within the program (or it may depend on which user/account runs the program).

Share this post


Link to post
Share on other sites
If the program is using a lot of processor time, it's going to affect things no matter what the priority is.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
If the program is using a lot of processor time, it's going to affect things no matter what the priority is.


While true, there's no reason why a long-running task cannot be assigned low priority, so user doesn't notice it. They will only become immediately noticable if they use disk, use extensive memory to cause paging, or hog some other resource, such as network.

Often, there's no need to modify the application at all. Just tell your OS to start the application in a certain way. See here for examples.

Share this post


Link to post
Share on other sites
Quote:
Original post by KontosHarry
Cause I am making a program which needs to run at startup and it should not affect the CPU much...



Well , why you don't just execute functions at fixed time ??

For example , in your (imaginary)"proccess()" function , add something similar to this:



type application::proccess(arguments ?)
{
time_now = get_time_in_milliseconds
dt = (time_now - last_time)
last_time = time_now
cycles += (uint)(1*(uint)dt)
if(cycles >= 1000)
{
update stuff
cycles = 0
}


}




It should work pretty well...

Share this post


Link to post
Share on other sites
Antheus generally told you the right thing to do.

However, you can simulate this by using a low-priority thread doing the job. At least in .NET is very easy and I've tested it - it really works. If you do it in C++, you can always make the thread sleep a while :D. But multithreading is by far the easiest way to go programatically.

Share this post


Link to post
Share on other sites
Poor little KontosHarry, too many asking why he wants to do that (although with very good reasons) but he's still waiting for the answer.

In Windows, this means you're looking for the SetPriorityClass() function.
I don't know how to do it in other OSes

Cheers
Dark Sylinc

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!