On Jan 14, 2008 1:30 PM, Andreas Kahari <[EMAIL PROTECTED]> wrote:
> On 14/01/2008, Alexander Schrijver <[EMAIL PROTECTED]> wrote:
> > On Jan 14, 2008 11:52 AM, Andreas Kahari <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > >
> > > Is there a way of limiting the amount of CPU given to a particular
> > > process or process group? For example, I would want the build of the
> > > qt4 port to use a maximum of 25% of the available CPU, leaving the CPU
> > > 75% idle if nothing else is happening on the machine.
> > >
> > > I know about 'nice', but it doesn't fulfil the criteria that the
> > > machine is left otherwise idle if nothing else runs on it.
> > >
> > > I don't have a real reason for why I would want to do this, I'm mainly
> > > curious as to if it's possible.
> [cut]
> >
> > I have never done this myself, but I believe this is possible by
> > creating a login class in /etc/login.conf and set the cputime option.
> > See login.conf(5) for a better description.
>
> Hi Alexander,
>
> I believe that the cputime resource limit will limit the maximum
> amount of CPU time that the user may use in a session, which is not
> really what I asked for. I'd like the process or process group to run
> for as long as it needs to run, but that it only ever uses a fraction
> of the CPU power.
>
> It's like limiting the network bandwidth for a particular type of
> traffic, only this is about time on the CPU.
>
>
> Regards,
> Andreas
>
> --
> Andreas Kahari
> Somewhere in the general Cambridge area, UK
>
Yes, you are right. It is also possible to set a priority for a
process in a login class.
>From login.conf(5)
priority number Initial priority (nice) level.
This is not exactly what you want, but it is pretty close. I am
curious why do you want to set an exact limit and not let the
scheduler do this for you?