LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Linux process scheduling and CPU utilization (https://www.linuxquestions.org/questions/linux-general-1/linux-process-scheduling-and-cpu-utilization-871868/)

jigsaw207 03-30-2011 02:51 AM

Linux process scheduling and CPU utilization
 
Hi All,

I have a stupid question :redface: . Linux kernel has its own process scheduler algorithms and it grants processes the chance to run based on credit algorithm, according to this algorithm the more cpu time a process accumulates the lower its priority becomes.

My question: based on the above information, why we see sometimes one process eating up all CPU ? does it take high credit from the kernel ? or its instructions need more CPU cycles ?

specially java programs it takes alot of cpu utilization.

Thanks.

syg00 03-30-2011 04:16 AM

IIRC the CFS uses a r-b tree to track process usage - if there is no process more "deserving" of using the processor, a "hungry" task will continue to get scheduled.
java is a CPU pig - well, it's just a piece of crap all round I guess ...

hf2046 03-30-2011 05:02 AM

Quote:

Originally Posted by jigsaw207
I have a stupid question . Linux kernel has its own process scheduler algorithms and it grants processes the chance to run based on credit algorithm

Not a stupid question at all. If you really want to know the answer, you probably need to look at this book (now horrendously outdated) - Understanding the Linux Kernel - Process Scheduling - and then diving into the kernel source itself. Most of the relevant code is in linux/kernel/sched.c. There are different scheduling policies depending on your kernel version and whether they're enabled or not. I'd be curious to know how the 2.6.x kernel does it as I only mucked around with the kernel when it was 2.2.x and I was in school...

onebuck 03-30-2011 08:27 AM

Hi,

Welcome to LQ!

Kernel Interactive Map will help you to understand visually.

If you look at Linux Kernel section of Slackware®-Links
you can find several good reference links;

Quote:

Anatomy of the Linux kernel: 'The Linux® kernel is the core of a large and complex operating system, and while it's huge, it is well organized in terms of subsystems and layers. In this article, you explore the general structure of the Linux kernel and get to know its major subsystems and core interfaces. Where possible, you get links to other IBM articles to help you dig deeper'
IBM's white-paper provides some useful insight.

Two good links to books;
Quote:

Linux Kernel in a Nutshell: Good read! downloadable
KernelBooks: Covering Linux 2.4 and Linux 2.6, as well as particular kernel subsystems
In the above you will find loads of definitive information. Some will be dated but relative to the current kernel. If you look at Kernel Newbies Frontpage you can keep up to date with changes.
:hattip:

jigsaw207 03-31-2011 02:16 AM

Thank you all very much, I will go through the links you provided and read more, you were a great help.

The idea of my question was to try to understand when it is bad to have high CPU load and when this load affects server performance as long as there is a scheduling algorithm that takes care of giving the opportunity for each process to run and this algorithm want to utilize the CPU as much as possible. This is the source of my confusion I guess :)

Thanks alot guys you are the best :)


All times are GMT -5. The time now is 12:33 AM.