What is the basic difference between NPTL and POSIX threads? How have these two evolved?
The Native POSIX Thread Library (NPTL) is an implementation of the POSIX Threads specification for the Linux operating system.
POSIX Threads, commonly known as pthreads, is an execution model that exists independently from a language, as well as a parallel execution model. It allows a program to control multiple different flows of work that overlap in time.
A Pthread is the POSIX specification for thread behavior, so is an abstraction, which the systems programmer sees and directly uses. A kernel thread is the entity actually created, scheduled and managed by the kernel as the context to execute a thread in a process.
An implementation of the POSIX threads API for Windows Also known as "pthreads-win32", POSIX Threads for Windows implements a large subset of the threads related API from the Single Unix Specification Version 3.
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.
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).
"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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With