[X-Unix] limit cpu usage

Robert Tillyard rob2 at atvetsystems.com
Thu Nov 25 02:27:27 PST 2004


Sorry to reply to the follow-up but I deleted the original.

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().

Regards, Rob.

On 25 Nov 2004, at 4:41 am, William H. Magill wrote:

> On 24 Nov, 2004, at 20:29, Brian Medley wrote:
>> I've googled around, but haven't found an answer to this
>> question.  I would like to limit the max % cpu a process can
>> have.  Something similar to ulimit; however, ulimit only allows
>> limiting the number of cpu seconds a job can run.
>
> This is not philosophically possible on a Unix system.
>
> What you want to do is a common resource control feature found in 
> Enterprise Class systems like VMS and MVS, but not Unix.
>
> Over the years, there have been any number of companies who have 
> written Kernel code to create a "resource management" system for Unix 
> -- but they tend to cost big bucks and only run on "mainframe class" 
> Unix boxes ... AND, they never really work the way one expects them to 
> work anyway.
>
> The reason is a long discussion of Operating System theory, but 
> briefly put, Unix simply does not have the "hooks" necessary to 
> implement any useful kind of Resource Control.
>
> T.T.F.N.
> William H. Magill



More information about the X-Unix mailing list