Does OS allocate each process to a separate core?

15

4

Ok I know the classic argument for avoiding quad cores. At the application level, most applications haven't been written for multiple cores. Most desktop software doesn't even need parallelization.

However, at the OS level, it seems obvious that the OS would divide up processes across the various cores. Wouldn't this be by itself an argument for getting more cores? Doesn't that help out a lot in many situations? You get a few CPU intensive tasks going--those processes might each be hogging 100% of their cores, but I can still browse the web and ask questions on SuperUser on my last core.... right ?

Doug T.

Posted 2010-09-11T23:38:57.410

Reputation: 1 891

A fundamental flow to this question and the answers is the assumption that a single process is single-threaded. This is not the case in many instances. And even if the process is single-thread, several system libraries/dll add their own threads. – harrymc – 2010-09-12T16:57:35.000

Answers

12

The OS cannot split an individual single-threaded process across multiple cores (although it may change which core an application is running on, but that's a different question), however it can run multiple processes, each on its own core. So, yes, if you have multiple processor intensive applications running in the background, it is likely you will still have a spare core sitting around doing little or nothing you can use to run other applications.

heavyd

Posted 2010-09-11T23:38:57.410

Reputation: 54 755

The key word here is if you have multiple processor intensive applications — that's an uncommon situation for most users. – Gilles 'SO- stop being evil' – 2010-09-12T00:37:56.243

Thanks for the response. Yes the latter case is what I'm attempting to describe. – Doug T. – 2010-09-12T03:31:09.073

3

To add to @heavyd's answer, the reason for this is the OS does not have the ability to determine which parts of the process are OK to run in parallel and which are not. If a program is not designed to run on parallel cores, you can have routines within the application that are designed to run sequentially running at the same time. This can cause all sorts of issues (like if 2 routines use the same memory block but are not meant to run at the same time).

The OS can use multiple cores for multiple processes since it does that anyways, but spreading a single-core application across multiple cores will cause all sorts of unexpected behavior.

JNK

Posted 2010-09-11T23:38:57.410

Reputation: 7 642

Thanks. I understand that. My question may have been poorly worded. I meant to ask more about the os putting processes on separate cores. Not somehow magically making the single threaded process span cores. – Doug T. – 2010-09-12T03:35:19.770

3

When it comes down to it, it doesn't matter if a processor is at 1% usage or 95% usage (as long as it is stable at 95% and not peaking), programs will be running at the same speed as long as it isn't hitting 100%. Unused CPU cycles are simply wasted.

Because of this, Windows 7 (on compatible processors) has a technology known as "core parking" which basically disables unused cores on your computer in order to save electricity.

Single threaded applications are automatically put across to alternate cores - I am not sure on the technology behind this, but I know it works quite well.

William Hilsum

Posted 2010-09-11T23:38:57.410

Reputation: 111 572

2

Your initial sentiments are correct - there IS a negative slant toward multiple cores, and it's not really all that deserved.

Back in the day when most users only used their desktop PC for simple word processing, there may have been an argument. But these days, with things like browsers with multiple tabs, each in their own process (chrome and ie do process level separation for tabs) plus things like video decoders within web pages and extra tasks which could easily be offloaded like on-the-fly rendering of effects aka css3, even the browser alone can justify a reason for lots more ram, and a few cores.

Add to that the fact that some users might also be gaming on this PC, or using tools like garageband, imovie, handbrake, multiple cores can be a huge benefit.

It's not true to assume that you need to max out (ie. 100% cpu usage on a single core) a core in order for another core to be useful. Because we are talking parallelism here. Task switching within a cpu usually performs a batch of operations before it swaps its stack to another process. Not all of these tasks are cpu bound, so you won't see a cpu spike even though the core is locked.

Basically, you're right, but what is the most efficient number of cores? 2? 4? 12? This would most likely depend on the users habits... I tend to this 2-4 for most users, but I'm only guessing.

Rob

Posted 2010-09-11T23:38:57.410

Reputation: 21