Native POSIX T hread Library - Wikipedia, the free... http://en.wikipedia.org/w/index.php?title=Native_P...

Native POSIX Library

From Wikipedia, the free encyclopedia

The Native POSIX Thread Library (NPTL) is a software feature that enables the kernel to run programs written to use POSIX Threads fairly efficiently.

In tests, NPTL succeeded in starting 100,000 threads on a IA-32 in two seconds. In comparison, this test under a kernel without NPTL would have taken around 15 minutes. [1][2]

Contents

1 History 2 Design 3 See also 4 References 5 External links

History

Before the 2.6 version of the Linux kernel, processes were the schedulable entities, and there was no real support for threads. However, it did support a system call - 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 thread support (most of the previous pthread implementations in Linux worked entirely in userland). Unfortunately, it had a number of issues with true POSIX compliance, 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 re-written threads 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. NGPT was abandoned in mid-2003, at about the same time when NPTL was released.

NPTL was first released in Red Hat Linux 9. 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 preempt them when it

1 of 3 09/27/2009 08:01 PM Native POSIX T hread Library - Wikipedia, the free... http://en.wikipedia.org/w/index.php?title=Native_P...

arises, something that Windows was known to do better at the time. Red Hat claimed that NPTL fixed this problem in an article on the Java website about Java on Red Hat Linux 9.[3]

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.

There exists a tracing tool for NPTL, called POSIX Thread Trace Tool (http://nptltracetool.sourceforge.net/) (PTT (http://sourceforge.net/projects /nptltracetool/) ). And an Open POSIX Test Suite (http://posixtest.sourceforge.net/) (OPTS (http://sourceforge.net/projects /posixtest/) ) was written for testing the NPTL library against the POSIX standard. Design

NPTL uses a similar approach to LinuxThreads, in that the primary abstraction known by the kernel is still a process, and new threads are created with the clone() system call (called from the NPTL library). However, NPTL requires specialized kernel support to implement (for example) the contended case of synchronisation primitives which might require threads to sleep and wake again. The primitive used for this is known as a futex.

NPTL is a so-called 1×1 threads library, in that threads created by the user (via the pthread_create() library function) are in 1-1 correspondence with schedulable entities in the kernel (processes, in the Linux case). This is the simplest possible threading implementation.

An alternative to NPTL's 1×1 model is the m×n model where there are typically more userland threads than schedulable entities. In the m×n implementation, the threading library is responsible for scheduling user threads on the available schedulable entities; this makes context switching of threads very fast, as it avoids system calls. However, this increases complexity and the likelihood of priority inversion, as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler. See also

LinuxThreads Library (computer science) Green threads

2 of 3 09/27/2009 08:01 PM Native POSIX T hread Library - Wikipedia, the free... http://en.wikipedia.org/w/index.php?title=Native_P...

References

1. ^ Introducing the 2.6 Kernel (http://www.linuxjournal.com/article/6530) 2. ^ The Native POSIX Thread Library for Linux (http://people.redhat.com/drepper /nptl-design.pdf) 3. ^ Red Hat Linux 9 and Java 2 Platform, Standard Edition 1.4.2: A Winning Combination (http://java.sun.com/developer/technicalArticles/JavaTechandLinux /RedHat/)

External links

NPTL Design paper (http://people.redhat.com/drepper/nptl-design.pdf) NPTL Trace Tool (http://nptltracetool.sourceforge.net/) OpenSource tool to trace and debug multithreaded applications using the NPTL. Retrieved from "http://en.wikipedia.org/wiki/Native_POSIX_Thread_Library" Categories: Linux kernel | POSIX standards | Threads

This page was last modified on 26 June 2009 at 19:32. Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. See Terms of Use for details. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc., a non-profit organization.

3 of 3 09/27/2009 08:01 PM