[Ilugc] how to limit the usage of cpu and memory

  • From: shuveb@xxxxxxxxx (Shuveb Hussain)
  • Date: Fri May 20 23:36:57 2005

Hi,

any other work on GUI ,the system likes totally hung, and it takes 3 to 7
hours to complete.after that only the user can work, now they asking to do

Is it possibel to limit that process to use not more than 85% of cpu and
memory

There is a facility to limit the CPU time and memory size consumed by
a process. See setrlimit() system call man page for details. You can't
set usage based on percentage, however.

It actually does not make sense to limit a particular process to 85%
of the CPU. Most of the time, CPUs spend time idling. During that
time, it would only be wise to let the program use up full CPU and
finish sooner.

However, if system responsiveness is the problem, then you can try the
"nice" command. The nice command reduces the process's priority. Thus
when you run the problem program with nice -n19 <program>, the
process' priority is lowest. When you start another program, it
usually starts as a normal priority program and thus is provided with
more favor and is scheduled more often.
At the same time however, when there are no other processes to run,
the problem program runs, utilizing full CPU. This is much better than
fixing the % of CPU a process can use.

Please note that, however, if the program in question is very resource
hungry, uses up a lot of other resources other than CPU like memory,
etc, then you are in trouble again. The nice command affectes only CPU
usage.

There are a few kernel hackers researching on class based resource
allocation. There were patches avaiable as well. Using these patches,
I think you can limit resources based in network usage, cpu usage,
etc.. I read this long back and can't guaruntee its correctness.
Please google.

--shuveb

Other related posts: