Native POSIX Thread Library: Difference between revisions

Content deleted Content added
added a comparison
Bender the Bot (talk | contribs)
m HTTP to HTTPS for SourceForge
 
(144 intermediate revisions by more than 100 users not shown)
Line 1:
The '''Native POSIX Thread Library''', also known as ('''NPTL,''') inis thean worldimplementation of the [[LinuxPOSIX kernelThreads]] isspecification afor feature that enablesthe [[Linux]] to run programs written to use [[POSIX]]-style [[Thread (computer science)|threads]] veryoperating fastsystem.
 
== History ==
In tests, it succeeded in running 100,000 threads simultaneously on a [[IA-32]] which were started in two [[second]]s. In comparison, this test under a kernel without NPTL would have taken around 15 minutes.
Before the 2.6 version of the [[Linux kernel]], processes were the schedulable entities, and there were no special facilities for [[Thread (computer science)|threads]].<ref>[https://web.archive.org/web/20210929083526/https://man7.org/linux/man-pages/man7/pthreads.7.html pthreads(7) — Linux manual page]</ref>
However, it did have a [[system call]] — {{mono|[[clone (Linux system call)#Clone|clone]]}} — which creates a copy of the calling process where the copy shares the address space of the caller. The [[LinuxThreads]] project used this system call to provide kernel-level threads (most of the previous thread implementations in Linux worked entirely in [[Userland (computing)|userland]]). Unfortunately, it only partially complied with POSIX, particularly in the areas of signal handling, scheduling, and inter-process synchronization primitives.
 
To improve upon LinuxThreads, it was clear that some kernel support and a new threading library would be required. Two competing projects were started to address the requirement: [[NGPT]] (Next Generation POSIX Threads) worked on by a team which included developers from [[IBM]], and NPTL by developers at [[Red Hat]]. The NGPT team collaborated closely with the NPTL team and combined the best features of both implementations into NPTL. The NGPT project was subsequently abandoned in mid-2003 after merging its best features into NPTL.
 
NPTL was first came outreleased in [[Red Hat]] Linux 9.0. Old-style Linux POSIX threading is known for having trouble with threads that refuse to yield to the system occasionally, because it does not take the opportunity to preemptively yieldpreempt them when it arises, something that Windows iswas known forto doingdo better at the superiorlytime. Red Hat claimed that NPTL fixed this problem in an article on the [[Java (programming language)|Java]] website about Java on Red Hat Linux 9.<ref>[https://web.archive.org/web/20110604035631/http://java.sun.com/developer/technicalArticles/JavaTechandLinux/RedHat/ Red Hat Linux 9 and Java 2 Platform, Standard Edition 1.4.2: A Winning Combination]</ref>
== History ==
NPTL first came out in [[Red Hat]] 9.0. Old-style POSIX threading is known for having trouble with threads that refuse to yield to the system occasionally because it does not take the opportunity to preemptively yield them when it arises, something that Windows is known for doing superiorly. Red Hat claimed that NPTL fixed this problem in an article on the [[Java programming language|Java]] website about Java on Red Hat 9.
 
NPTL has been part of [[Red Hat Enterprise Linux]] since version 3, and in the Linux kernel since version 2.6. It is now a fully integrated part of the [[GNU C Library]].<ref>[http://lists.gnu.org/archive/html/info-gnu/2004-08/msg00002.html GNU C Library version 2.3.3 release]</ref>
== NPTL vs. Windows Threading Experiments ==
In [[research]] done by Edward Rice in [[February]] of [[2004]], NPTL was compared to the [[Microsoft_Windows|Windows]] Threading Library. A program written in Java created multiple threads that ran at the same time. This program was run on both Windows and Linux on a dual boot system [[Intel]] non-[[hyper-threading]] chipset. It was discovered that Windows handled threads that yielded often better than Red Hat Linux 9, but Red Hat Linux 9 handled threads that yielded less frequently better than Windows. It was concluded that this was the result of the [[time]] it takes for a thread to yield and the [[virtual machine]] to pick a new one.
 
There exists a tracing tool for NPTL, called [https://nptltracetool.sourceforge.net/ POSIX Thread Trace Tool] ([http://sourceforge.net/projects/nptltracetool/ PTT]). And an [http://posixtest.sourceforge.net/ Open POSIX Test Suite] ([https://sourceforge.net/projects/posixtest/ OPTS]) was written for testing the NPTL library against the POSIX standard.
See also: [[Library (computer science)|library]]
 
==Design==
[[de:Native POSIX Thread Library]]
Like LinuxThreads, NPTL is a 1:1 threads library. Threads created by the library (via ''pthread_create'') correspond one-to-one with schedulable entities in the kernel (''processes'', in the Linux case).<ref name="lsp-love">{{Cite book |title=Linux System Programming |author=Robert Love |edition=2nd |isbn=978-1449339531 |date=2013|publisher=O'Reilly Media, Incorporated }}</ref>{{rp|226}} This is the simplest of the three [[Thread (computing)#Threading models|threading models]] (1:1, N:1, and M:N).<ref name="lsp-love"></ref>{{rp|215–216}} New threads are created with the clone() [[system call]] called through the NPTL library. NPTL relies on kernel support for [[futex]]es to more efficiently implement user-space locks.<ref name="lsp-love"></ref>{{rp|182}}
 
==See also==
{{Portal|Free and open-source software}}
 
* [[LinuxThreads]]
See also:* [[Library (computer science)|library]]
* [[Green threads]]
 
==References==
{{Reflist}}
 
==External links==
* [https://nptltracetool.sourceforge.net/ NPTL Trace Tool] OpenSource tool to trace and debug multithreaded applications using the NPTL.
 
{{Linux}}
 
[[de{{DEFAULTSORT:Native POSIXPosix Thread Library]]}}
[[Category:Linux kernel]]
[[Category:C POSIX library]]
[[Category:Threads (computing)]]