Kernel-level threads (like Linux and some *BSD systems) or something else? If there is any difference, I'm using pthreads.
2 Answers
Old question, but could use some more detail and accuracy:
The underlying threads in XNU (the OS X and iOS kernel) are indeed Mach threads, but these are generally hidden from user mode. Instead, there are BSD threads (also known as uthreads) over them, which are more accessible via the system calls (such as #360, bsdthread_create, and friends). PThreads actually further wrap these threads. In this way, a call to pthread create falls through to the system call bsdthread_create, which in turn (in kernel mode) invokes thread_create.
Mach calls can be called directly from user mode (via the Mach Interface Generator, MIG generated files in /usr/include/mach/*). This comes in very useful for debugging/tracing/hacking threads. But otherwise, for all intents UNIX-like, you're better off with the pthreads wrapper which (for the most part) is portable.

- 1,098
- 8
- 7
They are Mach threads.

- 124,830
- 17
- 198
- 235
-
2And in English: http://books.google.com/books?id=K8vUkpOXhN4C&pg=PA730&dq=OSX+pthread_create&hl=en&ei=xK8KTbnZPIT78AaVqrCfAQ&sa=X&oi=book_result&ct=result&resnum=1&ved=0CCMQ6AEwAA#v=onepage&q&f=false – Cody Gray - on strike Dec 17 '10 at 00:33
-
1Thanks. That doesn't directly answer my question, but from http://docs.google.com/viewer?a=v&q=cache:hDamQq6VffkJ:www.arl.wustl.edu/~fredk/Courses/cse522/fall03/Lectures/threads.ppt+mach+threads+kernel-level&hl=pl&pid=bl&srcid=ADGEEShkOaLiHkYeCZd02esRsX2FCqeYYe4gSCEpa4-YYf0z9KneErv9ivZt-Qec77qawty9KtXNJvh7LxGJtLXdllqMrKMAjM10qVyqawgnAR_XYxvS5xxI2nyvatONInc8CU0RPh_x&sig=AHIEtbRh_1hv1n2_hiNkpASPmcQsLJyXrw looks like these are kernel-level – Pyetras Dec 17 '10 at 00:52
-
1Well... In a microkernel, there are actually two kernels: the microkernel, and the operating system "kernel" (which actually may be spread over several tasks). So they are *not* OS kernel threads, but microkernel threads. – Martin v. Löwis Dec 17 '10 at 08:51