- 论坛徽章:
- 0
|
Linux从哪个版本开始兼通posix线程库?
原帖由 "精简指令"]我不是指那个术语。内核不支持的话,它还是把它当作一个进程那样调度。但是用户是以线程的方式使用。这样说不知道对不对,但我的理解是这样。[/quote 发表:
我觉得值得商榷。你说的这个“内核不支持”的情况,就意味着1:n,OS只知道有个进程存在,而这个进程中所有的线程,对OS来说都是透明的,不可见的。因此,调度就只能通过线程库来模拟,在线程(s)所属的进程内执行。因为OS不管线程的调度,所以在SMP中不可能做到并行。
下面是LinuxThreads官方页面的话:
[quote]Unlike other implementations of Posix threads for Linux, LinuxThreads provides kernel-level threads: threads are created with the new clone() system call and all scheduling is done in the kernel.
见http://pauillac.inria.fr/~xleroy/linuxthreads/
我翻译一下:
与Linux上的其它posix线程库的实现不同,LinuxThreads提供了内核级别的线程:线程(s)使用新的clone系统调用创建,并且由内核实施调度。
然后,再看看http://kerneltrap.org/node/422/1142上的新闻,了解到Linux上的posix线程库一共有3个实现:
1,LinuxThreads,1996年实现,已经被加入到glibc中,维护者不再是原作者,而是glibc team,确切的说,就是Ulrich Drepper。他是RedHat公司的工程师。
2,IBM实现的NGPT
3,RedHat的NPTL,正在设计与开发中,kerneltrap上说将来会成为Linux上的posix线程库的标准实现。主意其作者正是Ulrich Drepper,目前LinuxTreads的维护者。
这三个实现之间的性能比较,看看Drepper本人的实验:Ulrich Drepper recently offered some interesting benchmark results, comparing the time it takes to create and destroy threads with different threading models under various conditions. The tests were run using a 2.5.37 development kernel, comparing LinuxThreads, NGPT 2.0.2 and NPTL 0.1.
The results of these benchmarks are available in two pdf charts: [chart one] [chart two]. They suggest that while NGPT is twice as fast at thread creation and destruction than LinuxThreads, the new NPTL [story] is still four times faster than that! Read on for Ulrich's full explanation...
在IA32机器上,NGPT是LinuxThreads的2倍,NPTL是NGPT的5倍。以上消息请参考http://kerneltrap.org/node/429?PHPSESSID=cf32edae30f893bafebba80631cf738a
我就胡乱查了这些资料先,慢慢再来理清楚到底目前的linux实现是怎么进行调度的(瞎说一句,如果stevens尚在人世,肯定有精彩的著作给我们理清头绪) |
|