LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 07-09-2008, 04:20 AM   #1
stoyboy
LQ Newbie
 
Registered: Apr 2007
Posts: 6

Rep: Reputation: 0
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.
 
Old 07-09-2008, 04:32 AM   #2
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
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
 
Old 07-09-2008, 04:36 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 62
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.
 
Old 07-09-2008, 05:50 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,801

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
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 ...
 
Old 07-09-2008, 06:06 AM   #5
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
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)
 
Old 07-09-2008, 09:01 AM   #6
lurko
Member
 
Registered: Jun 2006
Location: Ontario, Canada
Distribution: Debian
Posts: 448

Rep: Reputation: 35
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.
 
Old 07-09-2008, 03:56 PM   #7
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,092
Blog Entries: 2

Rep: Reputation: 109Reputation: 109
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.
 
Old 07-09-2008, 07:06 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,801

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
"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.
 
Old 07-09-2008, 07:48 PM   #9
Tuttle
Senior Member
 
Registered: Jul 2003
Location: Wellington, NZ
Distribution: mainly slackware
Posts: 1,289

Rep: Reputation: 52
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)
 
Old 07-10-2008, 02:26 AM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,801

Rep: Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923Reputation: 923
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
script to get cpu usage idle % LinToWinWin Linux - Software 7 03-23-2006 01:34 AM
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
CPU idle binumvk Linux - Security 0 10-16-2004 04:19 AM
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li rags2k Programming 4 08-21-2004 04:45 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration