OS X 有什么类型的线程?

发布于 2024-10-08 04:48:31 字数 61 浏览 2 评论 0原文

内核级线程(如 Linux 和某些 *BSD 系统)还是其他?如果有什么区别,我正在使用 pthreads。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗心人 2024-10-15 04:48:31

老问题,但可以使用更多细节和准确性:

XNU(OS X 和 iOS 内核)中的底层线程确实是 Mach 线程,但这些线程通常对用户模式隐藏。相反,它们之上有 BSD 线程(也称为 uthread),可以通过系统调用(例如 #360、bsdthread_create 等)更容易访问这些线程。 PThreads实际上进一步包裹了这些线程。这样,对 pthread create 的调用就会转到系统调用 bsdthread_create,而系统调用 bsdthread_create 又会(在内核模式下)调用 thread_create。

Mach 调用可以直接从用户模式调用(通过 Mach 接口生成器,MIG 在 /usr/include/mach/* 中生成文件)。这对于调试/跟踪/黑客线程非常有用。但除此之外,对于所有类似于 UNIX 的意图,您最好使用 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.

苏大泽ㄣ 2024-10-15 04:48:31

它们是Mach 线程

They are Mach threads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文