[X-Unix] limit cpu usage

James Bucanek subscriber at gloaming.com
Fri Nov 26 07:06:46 PST 2004


Ken Rossman wrote on Thursday, November 25, 2004:

>While you aren't specifically strictly limiting CPU usage percentages by hard
>values, you ARE assigning priority orders by assigning processes to different
>scheduler queues with different runtime priorities.
>
>So, in "unix" (at least Solaris unix) this IS philosophically possible to do.

No, you're missing the "philosophy" part.  In every "UNIX" kernal I've ever dealt with, the kernel never decides _if_ a process should be run, only _which_ process should be run next.  Whether a process is ready to run or not is a decision left to the process.

Creating a CPU limit for a process would require the kernel to keep track of the how much resources a process has used and stop/suspend/ignore that process even though that process is ready to run.  This is something the kernel is simply not equipped to handle.

Now when it comes to prioritization, there are lots of variations between kernel implementations.  Some are extremely simple, others are complex and flexible.  But no matter how you prioritize, a process that's ready to run will still get CPU time if no other processes are ready.

Personal note: I wouldn't want a kernel that did this kind of process (micro)management.  The worst thing it would do is add unwanted overhead to the task switcher[1].  And I've never heard a compelling argument as to why an idle CPU should be kept idle when you have a process that's ready to run.  Prioritization works amazingly well, when used intelligently.

James

[1] Having written two multi-tasking kernels in my day, I can tell you that every cycle counts when doing context switches.  You really don't want a lot of "bean counting" going on during every time-slice.
-- 
James Bucanek <mailto:privatereply at gloaming.com>


More information about the X-Unix mailing list