Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Multithreading on Mac OS X

I've recently read somewhere on the Web that Mac OS X has no concept of multithreadiing. I'm assuming from this that OS X uses some form of coarse-grained scheduling based on task/process. How does the Java VM run on OS X? Java apps rely on multithreading within the VM.

Thanks.

Windows Vista

Posted on Jun 2, 2009 8:35 AM

Reply
18 replies

Jun 2, 2009 9:13 AM in response to IPEnthusiast

Since you sound like a knowledgeable programmer, I will assume you have installed or will install soon the Developer Tools package. When that is done, go into the /Developer/Applications/Performance Tools/ folder and run Thread Viewer. You will either attach it to an already-running application or use it to start a new application, after which you will get a window where you can see in real time all the threads being used by the chosen application, down to the specific code being executed. Knock yourself out... 😀

Side note: I'd suggest you register yourself on the [Apple Developer Connection|http://developer.apple.com> (there's a free registration option) so you can download the very latest version of the Developer Tools, as well as many other development goodies.

Jun 2, 2009 9:15 AM in response to IPEnthusiast

Hi IPEnthusiast;

With OS X being based on Unix, I would have to say that it is multithreaded. It is most certainly more capable of multithreading then anything from M$.

In the years of IT support that I have done, I can't believe how poorly Windows is at multithreading and utilizing multiple CPUs. So many times the customer would for Windows and later we would run Unix on the same server hardware and get significantly better perform simply by migrating off of Windows.

Allan
User uploaded file

Jun 2, 2009 11:25 AM in response to Allan Eckert

Well, simply because Mac OS X is based on UNIX, it can't be assumed that the OS is multithreaded. Multithreading is a concept that came around way after the first UNIX OSes were developed. And this actually manifested itself in earlier versions of the Linux kernel that simulated threads by actually launching a whole process in place of a thread, to take advantage of the process scheduler. Linux was firmly based on old UNIX code, I believe the implementation was called Minix.

Jun 2, 2009 12:04 PM in response to IPEnthusiast

IPEnthusiast,

When you open the Terminal, you can type

ps -ax


and list all the processes in Mac OS X as individual threads.

When you read the website from Apple Developer, any programmer following Apple's guidelines will make at least Posix compliant threads if not Cocoa. There are naturally some issues with Carbon programming, stated here:

http://www.macintouch.com/m10carbon.html

So as long as you are running all non-legacy code, you should be good to go.

Jun 2, 2009 12:23 PM in response to IPEnthusiast

IPEnthusiast wrote:
Well, simply because Mac OS X is based on UNIX, it can't be assumed that the OS is multithreaded. Multithreading is a concept that came around way after the first UNIX OSes were developed.


Multithreading is mandated by Posix, and OS X 10.5 is fully Posix compliant. In fact it is UNIX 03 registered, and therefore it is Unix. See Mac OS X Leopard: Technology for more.

If you want to know more about threads in OS X, try
man 3 pthread

And this actually manifested itself in earlier versions of the Linux kernel that simulated threads by actually launching a whole process in place of a thread, to take advantage of the process scheduler. Linux was firmly based on old UNIX code, I believe the implementation was called Minix.

On the other hand, Linux and Minix were, and are, not Unix. Neither were "based on" old Unix code.

Jun 2, 2009 12:50 PM in response to Allan Eckert

And the robust combination of Windows Server/SQL Server has not figured atop the TPC OLTP benchmark with a poorly designed OS. While SQL Server itself uses its own scheduler, the underlying OS plays a very crucial part in how the database engine performs. Since the introduction of distributed partitioned views in SQL Server 2000, Microsoft has consistently blown the top off of the TPC benchmark. You just have to know how to tune these products.

Multithreading on Mac OS X

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.