开发者

What type of threads does OS X have?

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


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.


They are Mach threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜