What type of threads does OS X have?
Asked Answered
L

2

5

Kernel-level threads (like Linux and some *BSD systems) or something else? If there is any difference, I'm using pthreads.

Lagomorph answered 16/12, 2010 at 23:44 Comment(0)
Z
2

They are Mach threads.

Zachery answered 16/12, 2010 at 23:49 Comment(3)
And in English: books.google.com/…Selfimmolation
Thanks. That doesn't directly answer my question, but from docs.google.com/… looks like these are kernel-levelLagomorph
Well... 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.Defecate
M
10

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.

Mackmackay answered 26/8, 2012 at 17:23 Comment(0)
Z
2

They are Mach threads.

Zachery answered 16/12, 2010 at 23:49 Comment(3)
And in English: books.google.com/…Selfimmolation
Thanks. That doesn't directly answer my question, but from docs.google.com/… looks like these are kernel-levelLagomorph
Well... 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.Defecate

© 2022 - 2024 — McMap. All rights reserved.