[X-Unix] limit cpu usage

Eugene list-themacintoshguy at fsck.net
Thu Nov 25 12:43:49 PST 2004


On Thu, Nov 25, 2004 at 10:27:27AM +0000, Robert Tillyard wrote:
: 
: Traditionally in Unix if you need to restrict the CPU usage you would 
: just drop the process priority using nice(). If the system is idle it 
: still allows the process to take the idle CPU capacity but gives 
: priority others with a normal priority.
: 
: I think on OS X this is done with getpriority() and  setpriority(). 
: You'll need to look at the man pages to see how to do this and I've 
: only ever used nice() before and I can't see man pages for nice().

Changing a process' priority only adds hints to the scheduler.
It still doesn't really *limit* the CPU usage of a process.
For example, you could drop the priority of a running process
that's doing something useful for you.  When you are on your
machine and doing other work, that process rarely gets any time
to run because its priority is so low (set by you) compared to
all the other processes running (the active work you are doing).
But when you stop working and your machine is relatively idle,
there's very little in contention.  So that running process will
get scheduled a lot of CPU use because no other process needs
the CPU.


-- 
Eugene Lee
http://www.coxar.pwp.blueyonder.co.uk/


More information about the X-Unix mailing list