What is the difference between NPTL and POSIX threads?
I guess your best source of information is starting on Wikipedia and following the links from there.
There is really no difference: NPTL is just the current Linux implementation of POSIX threads, you still use the pthread_* family of functions. Earlier in Linux history, a dedicated library called libpthreads was used. NPTL appeared for 2.6+ kernels circa 2003, see the link above for more details.
[BTW: NPTL == Native Posix Threads Library]
"POSIX threads" is a 'standard', defining an API for threading. i.e. it states that functions such as pthread_exit ()
etc, should exist in the system, and describes how they should behave. All POSIX compliant operating systems implement POSIX threads in their own way.
NPTL is a bunch of features that enables "Linux" (the kernel) to efficiently implement "POSIX threads" (the standard).
You can read more about NPTL and how it came about here
POSIX threads (pthread) is not an implementation, it is a API specification (a standard, on paper, in english) of several functions whose name starts with pthread_
and which are defined in <pthread.h>
header. POSIX is also a set of specifications.
NPTL is now inside GNU Libc on Linux and is (or at least tries very hard to be) an implementation of POSIX threads. It is a bunch of source and binary code on your Linux system.
An application compiled with gcc -pthread
and linked with -pthread
uses NPTL code on Linux today.
addenda
There exist alternative implementations of pthread
-s: on Linux, the MUSL Libc aims to be Posix compliant (which means having pthreads); on other Posix systems (AIX, Solaris, ...) you also have pthreads (but they are not NPTL or Glibc).