Thread: Process priority

  1. #1
    Registered User mikahell's Avatar
    Join Date
    Jun 2006

    Process priority

    Hi! I was wondering if there was a way to change a process's priority in order to increase one game's FPS or just to make a certain program going faster... I see that some applications are able to determine (like Windows's Task Manager) process priority, but in C++ is it possible to write code for this?

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Out of scope
    Yes, programs can change their own priority, though it's highly not recommended unless you're decreasing it priority. Search the MSDN library for the appropriate Windows function that changes the priority of an application. I don't know what it is and I've never seen it in code, I have however seen programs offer the option to set it's priority.
    Sent from my iPadŽ

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    I would perhaps suggest you let the user of your program decide. Messing with a process priority is not to be taken lightly since it may (and often will) affect the performance of other more critical processes.

    Also increasing the priority of a process is not a guarantee the app will run faster. It is simply a guarantee any resources will be lent to it before they are to other processes of a lower priority. This may or may not increase the performance.

    The solution for your problem, as I see it, is good quality code.

    The users themselves decide what they want to do with your app. Starting it from a batch file with "start /HIGH appname.exe" is good enough. Or simply using the control panel to increase the priority. It's their computer, their resources, their decision.

    Unless of course we are talking of some system critical application you are developing.

    EDIT: Which is definitely not the case in a game forum.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Registered User mikahell's Avatar
    Join Date
    Jun 2006
    Didn't even know that "start /HIGH appname.exe" was something possible to do...

    Well then I will let them choose, but I still am interested in playing around with this,
    so I got to msdn2 lib site and I found I had 2 functions for doing this, though these must have handles as parameters, and I don't really know how I can get to "catch" the handles of my application... What I know is this:

    SetThreadPriority(): needs a handle param. to the application
    SetPriorityClass(): needs a handle to a thread

    So I will continue looking for how to do "handle" variables, because this typedef seems
    rather confusing to me right now...

  5. #5
    Registered User Osaou's Avatar
    Join Date
    Nov 2004
    Stockholm, Sweden
    A handle is basically a reference to anything Microsoft-ish... Like windows, buttons, colours, fonts, error message returns, etc...
    So, you shouldn't create them yourselves, but have them handed to you by window creating functions and so forth.

  6. #6
    Join Date
    Jan 2006
    Please note that if you want to increase a process's priority, your program will need root permissions. I'm not completely sure, but I'm pretty sure that Windows programs run as root by default, however, if you were to write it for Linux or Mac, the program would look very suspicous asking for the root password to run.

    Yeah, if someone is serious about playing your FPS, then they'll probably quit all the other programs. Especially if your game is good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. init adopts zombie process?
    By password636 in forum Linux Programming
    Replies: 4
    Last Post: 07-01-2009, 10:05 AM
  2. create a child process that creates a child process
    By cus in forum Linux Programming
    Replies: 9
    Last Post: 01-13-2009, 02:14 PM
  3. Replies: 3
    Last Post: 10-15-2008, 09:24 AM
  4. Problem with forking a process
    By Unitedroad in forum C Programming
    Replies: 10
    Last Post: 10-04-2007, 01:43 AM
  5. process programming
    By St0rM-MaN in forum Linux Programming
    Replies: 2
    Last Post: 09-15-2007, 07:53 AM