LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Idle CPU usage (https://www.linuxquestions.org/questions/linux-general-1/idle-cpu-usage-654539/)

stoyboy 07-09-2008 04:20 AM

Idle CPU usage
 
I am trying to utilize the idle cpu on my computer, I would like to make it so that I can run a program in the background that will not interfere with my normal use of the computer. This is similar to the folding@home project running in the background of a computer. Btw this program is a simple bash script that I want running in the background. I want it to have as much cpu devoted to it as possible. Meaning that I want my cpu to run at about 80-90% at all times without slowing down my system any more then normal use.

Solution A
Create a new user and allow them a small amount of cpu time compared to the rest. I am not sure how to do this but I also know this is not utilizing idle cpu time but just reserving a specific amount of cpu

Solution B
Setup the program to have one of the lowest priorities possible and this should make it wait if something else is trying to use the cpu, something like firefox or azureus

Solution C?

Any idea and comments on how to actually execute these solutions or any others would be greatly appreciated.

Tuttle 07-09-2008 04:32 AM

try looking at the 'nice' value of the application, increase its 'nice' value at startup by running it thus:

Code:

nice [command] &
this will reduce its priority.

Code:

man nice

matthewg42 07-09-2008 04:36 AM

Running anything with no noticeable impact is difficult or impossible to achieve. No doubt your backgrounded program will use memory and probably a little IO from time to time, and that will inevitably affect other processes, although not by hogging the CPU.

The simplest thing is to run it in the background with a high nice setting. Using screen is a nice way as you can close the terminal and then re-attach to it later.

syg00 07-09-2008 05:50 AM

Allow me to disagree - in (at least one) other universe this concept is well understood. A few decades of history helps.
I had high hopes that CKRM would evolve to provide the controls (and measurements) needed. Unfortunately they got slapped down by the virtual server and cluster proponents - and the kernel devs in general.
Containers (and now cgroups) is a poor substitute, but will likely be the best you'll get for a while.

I happen to one of those that think that Linux has drifted away from its roots - even lost the plot in some ways ...

Tuttle 07-09-2008 06:06 AM

syg00:
Where does this leave us? Is nice not doing everything it is presumed to be doing?
Is CKRM an alternative method of handling priorities in the kernel or something?
Please enlighten! (or provide a link to enlightenment... no, not DR17 :P)

lurko 07-09-2008 09:01 AM

There's a program called cpulimit which will limit a given PID to a given percentage of CPU use. Runs into trouble if your program forks and a different PID than you specified starts using the CPU though.

estabroo 07-09-2008 03:56 PM

nice 19 or renice if its already running

I do this quite a bit with video compression, h.264 is a bit of cpu hog, so I'll run it a nice 19 and it'll chug along in the background without bothering what I'm doing even if I have the h.264 compressor using all the cpus.

syg00 07-09-2008 07:06 PM

"nice" has its place, but also has limitations. As do the alternatives, as per lurko above. Have a look at CKRM for some history.
Pity it got trampled on.

Tuttle 07-09-2008 07:48 PM

Thanks for the feedback syg00. Seems nice is quite basic. So, would the CKRM option appear next to anticipatory/deadline/cfq in the IO Schedulers section? Is nice directly connected with these schedulers or would a new piece of software have evolved to further control the new CKRM scheduler?
It's all rhetorical to me but it's nice to know these things (no pun intended)

syg00 07-10-2008 02:26 AM

CKRM is dead.
Those schedulers you mentioned are I/O schedulers, nothing (directly) to do with task dispatch (on a CPU).
Ingo has added some infrastructure to the CFS - group fair scheduling. Looks like it might do the job - I pulled 2.6.26-rc9 this afternoon and had a play. Done by UID it seems to be easy enough to utilise - using cgroups would be a bit messier. That (CGROUP_SCHED) is aimed more at non-desktop users I'd reckon - they would probably be looking to script it.


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