Specifications

Red Hat Enterprise Linux to Oracle Solaris Porting Guide
50
Chapter 5 Threads and Multiprocessing
POSIX Compliance
The standard POSIX.1c threads extensions (IEEE Std 1003.1c-1995) defines APIs for creating and
manipulating threads. POSIX threads, usually referred to as Pthreads, is a POSIX standard for threads.
POSIX.1 specifies a set of interfaces (functions and header files) for threaded programming. Oracle
Solaris Studio as well as GNU compilers support the POSIX threads programming model.
Linux Threading Model
On RHEL, two threading implementations have been provided over time by the GNU C library
(glibc). Both of these are so-called 1:1 implementations, meaning that each thread maps to a kernel
scheduling entity:
LinuxThreads. This is the original Pthreads implementation. (Since glibc 2.4, this implementation
is no longer supported.)
NPTL (Native POSIX Threads Library). This is the modern Pthreads implementation.
By comparison with LinuxThreads, NPTL provides “closer” conformance to the requirements of the
POSIX.1 specification and better performance when large numbers of threads are created. NPTL has
been available since glibc 2.3.2 and requires features that are present in the Linux 2.6 kernel.
Since glibc 2.3.2, the getconf command can be used to determine a RHEL system’s threading
implementation, for example:
bash$ getconf GNU_LIBPTHREAD_VERSION
NPTL 2.12
With older glibc versions, a command such as the following should be sufficient to determine the
default threading implementation:
bash$ $( ldd /bin/ls | grep libc.so | awk '{print $3}' ) | egrep -i 'threads|nptl'
where
nptl refers to the native POSIX threads library by Ulrich Drepper et al.
Selecting the Thread Implementation
On systems with a glibc version that supports both LinuxThreads and NPTL (for example, glibc
2.3.x), the
LD_ASSUME_KERNEL environment variable can be used to override the dynamic linker’s
default choice of threading implementation. This variable tells the dynamic linker to assume that it is
running on top of a particular kernel version. By specifying a kernel version that does not provide the
support required by NPTL, you can force the use of LinuxThreads. The most likely reason for doing
this is to run a (broken) application that depends on some nonconformant behavior in LinuxThreads,
for example: