What is the difference between NPTL and POSIX threads?

Whoami picture Whoami · Dec 20, 2011 · Viewed 12.9k times · Source

What is the basic difference between NPTL and POSIX threads? How have these two evolved?

Answer

Basile Starynkevitch picture Basile Starynkevitch · Dec 20, 2011

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).