Native POSIX Thread Library


The Native POSIX Thread Library is an implementation of the POSIX Threads specification for the Linux operating system.

History

Before the 2.6 version of the Linux kernel, processes were the schedulable entities, and there were no special facilities for threads. However, it did have a system callclone — 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. 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 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 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 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.
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 . And an 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. However, NPTL requires specialized kernel support to implement 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 are in 1-1 correspondence with schedulable entities in the kernel. This is the simplest possible threading implementation.
An alternative to NPTL's 1×1 model is the.