You are not logged in.

#1 2010-08-04 23:11:16

DWilliams
Member
From: Everywhere
Registered: 2009-11-22
Posts: 119

Why do some large processes hop between CPU cores?

I'm just curious. I was running unrar on a large (7GB) RAR. I happened to watch my CPU load monitor whilst it was doing so. I noticed that it will max out one of my 4 cores for a few seconds then pause for a bit then switch to another core and max it out.

Why is this? I assume this is something to do with the Linux kernel manipulating processes and not the unrar program itself. I don't have any big processes competing for CPU time, just normal backgroung processes running mostly. It seems like the job would complete faster if it just picked a core and stuck with it instead of all the pausing and switching

Here's a screenshot I took that demonstrates what I'm talking about (although it's easier to notice when watching it in real time)

alternating.png

Offline

#2 2010-08-05 07:00:55

Proofrific
Member
Registered: 2008-01-05
Posts: 215

Re: Why do some large processes hop between CPU cores?

Operating systems have something called a scheduler.  It decides what programs get to use the CPU, and when.  It gives a program use of the CPU for a certain amount of time, and then an interrupt will return control to the operating system.  Then, the scheduler picks the next program that can use the CPU.  It may be the same program as before, or a different one.  Regardless, control returns to the CPU when the interrupt occurs.  So, a program doesn't just stay with the CPU without any breaks.

If you're a college student and would like to learn more about this, I'd recommend taking a course on operating systems.

Offline

#3 2010-08-05 07:22:55

sand_man
Member
From: Australia
Registered: 2008-06-10
Posts: 2,164

Re: Why do some large processes hop between CPU cores?

To add to Proofrific's post, if you had changed the process's "nice" value you would notice a dramatic change in how the task was handled or "scheduled".


neutral

Offline

#4 2010-08-05 07:26:27

Proofrific
Member
Registered: 2008-01-05
Posts: 215

Re: Why do some large processes hop between CPU cores?

Good point, sand_man.  You can read about niceness on Wikipedia.  Basically, the niceness determines the priority of a program/process.  If a process is nicer, than it's more likely to yield to other processes.  If you make your process *not* nice, then the scheduler will give it more CPU time.

Offline

Board footer

Powered by FluxBB