Results 1 to 3 of 3

Thread: Set CPU usage limit on a particular app (Tough

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599

    Set CPU usage limit on a particular app (Tough

    Experts,

    got any idea of how to limit the cpu usage by a particular program ... say for example ... i would like to make the program utilize 50 % of the CPU processing ................... whatever the program does, it will definitely not gonna use the cpu processing power over 50%.....
    Thank You

  2. #2
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    I've an idea that almost does what u want. This idea suits well
    only if ur codes are in a loop.

    So, first, u need to collaborate the global CPU usage reading with
    ur app. Say, u check the CPU usage for 3 seconds, then get the
    average out of it. Say, it's about 2%.

    Then u run ur code loop, at the same time, check CPU usage. If it
    exceeds 52%(50%+2%), stop it, and check how many loops have
    been executed per second. Say, 100 loops per second.

    After that, everytime u execute ur loop, put some conditional
    codes that always check if the loops executed per second has
    exceeded 100 loops per second. If it is, then execute Sleep
    API with a value of 0 passed to it. By passing a zero value, u ask
    the program to give the remaining timeslice to other threads.
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599
    okay ... cool idea. /


    but my case is that (its not a fast loop). it is a timer loop... depending on the miliseconds value
    Thank You

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width