Does OS X parallelize code execution?

dakota

Registered
If you take an ordinary piece of code (C, Matlab) and simply run it on a dual G5 under Panther, does it mean both processors will be working on it or does the code have to rewritten?
 
If the application is multithreaded OS X will split the threads up between the 2 processors.

You may have a user interface thread and a worker thread, and one will run on each of the processors.
 
Captain Code said:
If the application is multithreaded OS X will split the threads up between the 2 processors.

You may have a user interface thread and a worker thread, and one will run on each of the processors.

I am not talking about applications so multitreading may not apply. Is C code multithreaded? Do you have to make it so? How do you do it?
 
dakota said:
I am not talking about applications so multitreading may not apply. Is C code multithreaded? Do you have to make it so? How do you do it?

C code is not inherently multithreaded.

You do so by dividing your code into multiple tasks and creating threads. For example, you might have one thread in a game that does pathfinding, while a different thread services the network communication.

One caveat (well, there's lots of caveats, but this is one that many people don't realize) is that in a GUI application, typically only the main thread can interact with the GUI.

Wade
 
Back
Top