Re: CPU limits
- From: xhoster@xxxxxxxxx
- Date: 07 Nov 2007 19:46:35 GMT
"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.
.
- References:
- CPU limits
- From: alexxx.magni@xxxxxxxxx
- CPU limits
- Prev by Date: Kaspersky 8.0 alpha 2 + key
- Next by Date: Unix Daemons in Perl -- Tutorial
- Previous by thread: CPU limits
- Next by thread: Re: CPU limits
- Index(es):
Relevant Pages
|