[Gllug] Forcing CPU and Mem limits on a process

Joel Bernstein joel at fysh.org
Fri Feb 11 14:32:23 UTC 2005


On Fri, Feb 11, 2005 at 01:50:26PM -0000, David Abbishaw wrote:
> Can anyone recommend how I can run a process and define that it can only
> use say 25% of the cpu and an amount of memory???  I thought nice would do
> the CPU but it doesnt look great.

Memory consumption is easy. There's a system call - ulimit(3) - which
you can use to do this. If bash is your shell, you have a ulimit
builtin.

Limiting to 25% CPU isn't doable, I don't think, but do you really need
to do this? UNIX works with process priorities, so you can use nice to
set a very low priority on the process. Thus on an unloaded system it
can take 100% CPU if it wants to, but other processes will have a
higher priority and be able to override this.

Of course, nice'ing the process won't let you guarantee that it will
always have 25% of CPU time, but then your system can only handle n
processes at a time, where n == number of CPUs.

If there *is* a way, I'd be interested to know what it is. I think you'd
need significant changes at kernel level to be able to do what you want,
and that would break all kinds of other things.

Do any other OSes have facilities for this? Perhaps QNX or another RTOS?

/joel
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list