That's hard to do and its unclear to me what the rationale would be, with the exception of power saving on a laptop. Search for "windows cpu throttle" and that will give you some ideas.

The normal thing would be for you to differentiate between what's important and what's not. This is a rough allocation of CPU resources and that's done by priority levels. Yes, even Windows has this idea. Type: "help start" at the command prompt. If you start a program at the IDLE priority level, that means when the CPU has nothing else to do, "run me". Now if the computer isn't really doing anything, then your program might take close to 100% of the CPU!

If you have something "more important" then you run it at a higher priority level. There are lots of levels, only a few of which are accessible from the command line, but more are accessible via various API's.

How the OS decides what to do next is of course very OS specific and this whole subject can get VERY complicated. But normally for the average user, saying just "I'm normal and should share with my peers", "I'm less important than other stuff" and "I'm really not that important at all" is enough (these are priority levels).

Update: Its summer time now and I don't run my CPU at 100% during the summer. But during the winter, especially on the cold nights...I crank this baby up! I donate CPU power to SETI@Home or Einstein@Home or one of the other BOINC projects. This basically turns my computer into a space heater!

This is an example of a "well behaved" low priority compute intensive task. I don't notice a difference at all in terms of response times, but the room stays warmer! When I'm not doing anything, one of the BOINC projects is maxing out my CPU MIPS. Anyway, instead of running electric space heaters, consider running the heck out of your computer in the interest of science! They've got the priority scheduling part right and it works. The watts that the space heater consumes does nothing useful besides heating the room. The watts that the computer consumes heats the room and at least has the potential for doing something useful.


In reply to Re: hogging N% of CPU ? by Marshall
in thread hogging N% of CPU ? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.