Re: CPU limits



"alexxx.magni@xxxxxxxxx" <alexxx.magni@xxxxxxxxx> wrote:
Inspired by the recent posting of "FAQ 8.39 How do I set CPU limits?",
I hoped to solve this problem, that I always had with computationally
intensive scripts - namely that the CPU usage goes to 100%, and a very
noisy fan starts.
I'd much prefer to be able to set my script's CPU usage at - say - 75%
or similar...

In the FAQ I saw that this possibility is in the BSD::Resource module,
but unfortunately I work in Linux.

BSD::Resource works under Linux. Or at least some (I expect all or most)
parts of it do. So I don't think that that is a problem.

Moreover, I'm not certain that even under BSD this could be possible:
setrlimit seems to allow you just to kill processes going beyond your
given threshold.

Yes, that is the problem. I don't know of any facility on any OS that does
this (but I haven't looked very hard.) I guess you could write a
baby-sitter process which goes into a loop where it sleeps for 3N
microseconds, then issues a kill STOP to your real process, then sleeps for
N microseconds, then issues a kill CONT to your real process. That should
restrict it to 75% CPU time. If your main program uses other types of
signals, this might not work very well.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.



Relevant Pages

  • Re: CPU user/kernel time given the PID
    ... I noticed the same after some digging through ... the source code for ps and top. ... While CPU usage % is a useful number also, ... the user time in seconds and microseconds, ...
    (freebsd-hackers)
  • svchost
    ... update, then run virus scan. ... processes and kill the svchost.exe that has the highest ... This should free up your CPU usage quite a bit, ...
    (microsoft.public.win2000.registry)
  • Re: CPU usage in Windows task Manager program
    ... Kill it. ... > unaware of I opened windows task managed then clicked processes then % ... > usage so that the most CPU usage was at the top of list, ... > only other figures that appeared there were taskmgr.exe & system idle. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Unix Process name to PID
    ... >> I find this to be the best one, but I am getting the command trying to kill ... not the real process. ... the portability police will tell us ...
    (comp.unix.shell)
  • Retrieving OS parameters specific to processes
    ... only that process which is consuming the CPU more. ... have to kill pid 225. ... How can I calculate the CPU usage based on PID? ...
    (comp.lang.basic.visual.misc)