如何在Linux上实现POSIX线程? [英] How are POSIX Threads implemented on Linux?

查看:174
本文介绍了如何在Linux上实现POSIX线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道通过pthreads库创建的线程实际上是内核级线程还是与内核无关的用户空间线程?我听说过对此有互斥的意见,所以我想知道真相.

I was wondering if threads created via the pthreads library are actually kernel-level threads or user-space threads that have nothing to do with the kernel? I have heard mutually exclusive opinions about this, so I want to know the truth.

推荐答案

在Linux 2.6之前,它们本质上是用户空间线程,它们是粘合在一起的独立进程,因为内核没有真正的线程支持.在2.6之前,对内核级线程(clone()函数)的支持有限,但是它并未与posix线程一起使用,仅与名为linuxthreads的替代线程库一起使用. 自 NPTL (本地Posix线程库)问世以来,它们就是内核线程.

Before Linux 2.6 they were essentially userspace threads, separate processes which were glued together, because the kernel had no real thread support. There was some limited support for kernel level threads (a clone() function) before 2.6, but it wasn't used with posix threads, only with an alternative thread library called linuxthreads. Since the arrival of NPTL (Native Posix Thread Library) the are kernel threads.

这篇关于如何在Linux上实现POSIX线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆