Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Would Mac OS X be able to distribute processes to the various cores in an Intel i7 Quad Core processor even if the applications are not multi-threaded?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

A thread is what the OS sees and what it schedules on a core to run.

Programs can be single-threaded or multi-threaded. Programs can also spawn other programs and communicate with them via process-level I/O techniques like pipes or file handles, etc. But from the OS' perspective these sub-programs are still just collections of threads. It doesn't really matter if the program is spawning multiple threads or if it's spawning sub-processes -- both approaches represent OS-level threads that the OS will attempt to schedule and execute as efficiently as possible and possibly in parallel.

If you have multiple cores and a program's threads aren't being explicitly locked to a core, then the OS can try run them at the same time, in parallel, across all the cores it has available to it in the current machine. If you have multiple programs running, the OS will schedule all those underlying threads across all the cores it has available to it in the current machine.

Practically speaking there's some amount of I/O, inter-process or inter-thread communication and synchronization that needs to occur and this can cause OS-level threads to block and keep things from running truly parallel all the time. For example: two threads in a multi-threaded program might be pulling values off a shared stack to do some work, so access to the stack has to be co-ordinated to ensure everything is thread safe and that means only one thread can pop from the stack data structure at time. There's a bottleneck in the program's design that's limiting thread parallelism to one here and the OS can't help with that.

The same is true for programs that spawn sub-processes. There may be I/O or inter-process synchronization issues that prevent all spawned sub-processes from truly running in parallel all the time.

share|improve this answer
    
Ian, thanks a lot for your input. Do you think that there would be any advantage over chosing a lower clocked quad over a high clocked dual i7 for tasks such as web development? (switching between Ruby run-time, web app server, tests, Java-based IDE, various browers loaded all at the same time) –  Jason Nov 7 '11 at 21:51
    
I would personally take more cores over a higher clock speed. Those tasks aren't generally CPU intensive, so being able to run more concurrent threads would be a greater advantage than being able to run one or two threads a little faster. –  Ian C. Nov 7 '11 at 21:53
    
Answer accepted. Just to clarify, OS X can let these apps run on all 4 cores, even if these tasks (Ruby, etc.) are not coded as multi-threaded apps. I keep reading that unless the applications are programmed as multi-threaded apps, there is no point in having the extra cores. This is why I am asking again. :) –  Jason Nov 7 '11 at 22:10
1  
@Jason absolutely. From the OS point of view it sees many, many threads from all the different programs. And it'll schedule them all, in parallel if possible. So the Ruby thread and the Apache thread and the Eclipse IDE threads could all be running simultaneously. –  Ian C. Nov 7 '11 at 23:12
    
Perfect. Thanks again. –  Jason Nov 8 '11 at 4:27
add comment

If the application itself is not multithreaded then it will stay to a single core. If you have a number of single threaded applications that are running it's reasonable to assume OS X will distribute them between he cores appropriately.

share|improve this answer
    
Ah, but this is the assumption that I am trying to verify. So far it is hard to find facts that back this up. –  Jason Nov 7 '11 at 21:38
    
I can expound upon this a bit: when the OS schedules a thread there's not any guarantee it'll run on the same core every time (unless the thread locks itself to a processor). So a single threaded application will run on any core available when the OS determines that it is time to run that application thread again. Make sense? –  Ian C. Nov 7 '11 at 22:04
    
Got it. Thanks! –  Jason Nov 7 '11 at 23:01
    
Let me be a bore and make one last inquiry. What would be the technical reason why an app such as a 3D game would perform less efficiently on a quad than on a dual core. I see that statement over and over again, but without any technical reason to back it up. –  Jason Nov 8 '11 at 0:42
1  
@Jason My guess is that the game stores a lot of data which it performs calculations on to generate the next frame. If the thread runs on a different core than it did the last time, there is an increased chance that that data won't be in the cache and will take longer to retrieve. Also, I think most places which claim more processors is worthless unless the app supports them are based off of the assumption that most processes take little if any processor time when not being actively used. –  ughoavgfhw Nov 8 '11 at 3:10
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.