[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: cpu amount



This is NOT the answer!

It is sick to see stupid monkeys answering reasonable questions with a
"man foo(1)" when they don't understand the question or don't
understand the man page to which they refer.

nice(1) addresses the scheduling priority, which in turn means the
ordering in which processes gets to run.  Rafael asks about how to
reserve a percentage of the CPU cycles, and it is a, though related,
totally different question.

The short answer is: You can't!

The longer answer is that the UN*X timesharing doesn't work this way.
You can't reserve a fixed slot of the timeshare system for a specific
purpose, and it is a strength and a weekness too.

The strength is, that you will only have empty cycles, if there simply
is not process willing to run.  When a process wants a ressource that
isn't available, it will sit and wait for it.  Only if has internal
work to do (like doing calculations, moving bits and bytes, etc.) it
will accept to run.

Take a ps -ax and look at all the processes just waiting for stuff to
happen.  So if they don't need to run, they should not take up a
(wasted) timeshare.  The processes ready to run is in a queue, where
they will scheduled (taken out for a run) based on a scoring system.

The nice(1) thing is, that there is a way to make a (single) process
ask for a lesser scheduling frequency, and therefore the name, like
a nice person is the supermarked that let people with less items in
their basket get in front.

The weakness is that you can't make a reservation for highly
synchroneous tasks that needs to run on a specific splitsecond.  There
are realtime OS'es that does that and does that good, but it is very
rarely a desired thing in a system like UN*X.

Another weakness in the UN*X scheduling system is, that it is not
possible to limit the number of process slots a user can get.  So a
fork bomb (a process that forks a number of children that in turn do
the same) can really bring a system to it's knees and mostly require
a reboot.

For further discussion of the topic refer to "The Design of the UNIX
Operating System" by Maurice J. Bach and maybe to "The Design and
Implementation of the 4.4 BSD Operating System" by Marshall Kirk
McKuisick, Keith Bostic, Michael J. Karels, and John S. Quarterman

--
Thomas Jørgensen, UNIX instructor and consultant.
SuperUsers A/S, Karlebogård, Karlebovej 91, DK-3400 Hillerød.


> -----Original Message-----
> From: Jan Muenther [mailto:jan@radio.hundert6.de]
> Sent: Friday, November 17, 2000 9:43 AM
> To: Rafael Coninck Teigao; misc@openbsd.org
> Subject: Re: cpu amount
> 
> 
> >     Is there anyway to limit the amount of CPU that a 
> process uses? Say
> > I want to always let my CPU 20% idle, is there a way to a make be
> > limited?
> 
> man nice
> -- 
> Radio HUNDERT,6 Medien GmbH Berlin
> - EDV -
> j.muenther@radio.hundert6.de
>