Thread: threads with lower CPU usage

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001

    threads with lower CPU usage

    Is it possible to limit a thread to use say max 25% of the CPU? Or is giving the thread a lower priority the only way to go here? What I'm trying to do is avoid lag in the main program while having a secondary CPU-consuming thread running in parallell.

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Newport, South Wales, UK
    The thing about thread priorities as I see it is that while you may have a particular amount of usage in mind, all prioritising seems to do is either allow your thread to take over the CPU or get almost completely ignored by it. Trying to code a task scheduler that runs thread THIS_MUCH_AND_NO_MORE is more trouble than it's worth.

    If you want fairly reliable fixed usage, you're gonna have to get clever with the sleep() function and units of about 100ms.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reduce CPU usage
    By patrick22 in forum Windows Programming
    Replies: 9
    Last Post: 07-10-2009, 02:13 PM
  2. questions on multiple thread programming
    By lehe in forum C Programming
    Replies: 11
    Last Post: 03-27-2009, 07:44 AM
  3. Net cpu usage of pthreads?!
    By mynickmynick in forum C++ Programming
    Replies: 15
    Last Post: 09-26-2008, 07:59 AM
  4. Calculating CPU Usage
    By vitaliy in forum Linux Programming
    Replies: 3
    Last Post: 08-21-2005, 09:38 AM
  5. CPU Usage so high
    By X PaYnE X in forum Windows Programming
    Replies: 9
    Last Post: 12-21-2003, 03:07 AM