LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Throttle CPU (https://www.linuxquestions.org/questions/linux-software-2/throttle-cpu-735911/)

dellthinker 06-26-2009 05:24 PM

Throttle CPU
 
Hi all, i know about bandwidth throttling, but i've never heard anyone ever throttling a cpu. I was wondering if it was possible. I have a perl program that tends to eat up the cpu bandwidth by like %34.50. Seeing how my machine is a 1.8GHz Pentium, it does have its limits. So does anyone have any useful solutions to my problem? Thanx in advance!

jlinkels 06-26-2009 05:55 PM

nice

It's a command called nice.

jlinkels

dellthinker 06-26-2009 06:11 PM

Can you give me an example on how to use it, i cant find any even with Google.

jlinkels 06-26-2009 07:34 PM

No, I can image if you google for "nice" that should yield 2e15 unusable results.

This is the man page: http://www.manpagez.com/man/1/nice/

And you use it like:
Code:

nice 40 myperlprogram
It will schedule your progam below most others, the higher the nice value, the nicer your program behaves.

But ...uhm.... it doesn't make your processor run slower when your program is the only one to run. Running any program requesting full power will increase the clock speed.

It will be difficult to achieve that as all power saving schemes are based on gives you as much CPU power as possible when you need it.

You might want to check settings of powernowd, and see if you can make it stick at a low CPU MHz value. Certainly you will google useful results, and also check "CPU clock throttling". A lot of sites will direct you to the speedstep.c program but I am not sure you are willing to recomplie your kernel for this, and it will be difficult you make your CPU listen to full power again. There might be an entry in /proc/sys/cpu which allows you to limit the clock speed as well.

jlinkels

johnsfine 06-26-2009 08:28 PM

Why/when do you want to "throttle" the CPU? It means enough different things depending on the purpose that we can't really give you a good answer without guessing/assuming what you really want (though the earlier answers might include the correct assumptions).

Usually people want to reduce the CPU usage of some task in order to make concurrent tasks run faster. That is what "nice" and related tools for manipulating process priority take care of.

Maybe you want to reduce CPU usage to reduce power consumption or heat generation. That is the purpose of tools like powernop, but those are biased toward only reducing the CPU speed when it isn't used much, even by low priority processes. Making that mechanism reduce the CPU available to the process you want to throttle, would be possible, but more difficult than the ordinary use of powernop.

Maybe you want to test a program to see how it would run with a less powerful CPU. There are ways to do that as well, but I don't want to guess that is what you mean.

So our best answer to "how" depends on your answer to "why" and maybe "when".


All times are GMT -5. The time now is 09:03 AM.