NPTL

Introduction
The goal of this document is to explain how to use the NPTL (Native POSIX Thread Library) of the uClibc instead of the old linuxthreads one. The NPTL is today experimental on Linux C6x and is not set by default as the pthread library. The following steps allow you to use NTPL based on the 2.0 release.

Installation
The NPTL is today only provided through Git in the new uClibc Git repositories. The NPTL library needs TLS support from the Linux kernel and an update of linux-c6x-project for building it.

The bootstrap command has been updated to take into account the new uClibc repository.

Ensure you have git and your have proxy configuration correct if you are behind a non-transparent firewall.

Issue the following commands

mkdir ~/my-linux-c6x cd   ~/my-linux-c6x wget http://linux-c6x.org/bootstrap chmod +x bootstrap ./bootstrap master

If you have already installed the product, you can also clone this new uClibc repository (the master branch) manually and install it in the same directory as linux-c6x/ and linux-c6x-project/ then pull the last changes of the master branches for both linux-c6x/ and linux-c6x-project/ Git repositories.

Build
By default uClibc is using the old linuxthreads library. In order to activate NPTL you need to do the following steps:


 * First re-generate and update the setenv file for enabling NPTL:

$ cd linux-c6x-project $ ./prj config $ vi setenv

Then modify the following lines:

export USE_NPTL=yes
 * 1) Use NPTL as uClibc POSIX thread library
 * 2) NPTL provides better performances and POSIX compliance.
 * 3) This feature is still experimental for the time being.

Follow the standard way of building the product as described in the Linux-c6x_2.0_Release:

$ ./prj config $ ./prj build clean $ ./prj build

Current Status
The NPTL current status is the following:


 * All the NPTL POSIX features are supported including per-thread signals, inter-thread synchronization, POSIX timers, POSIX.1 compliance.
 * TLS is emulated and we do not support it at the compiler level. It means that the __thread qualifier cannot be used with the correct behaviour in applications.
 * Static linking is supported but not fully tested.
 * GDB is not yet supported and thread_db has not been tested.
 * Cancellation is not yet fully supported when using the -fexceptions gcc flag. As a consequence pthread_cleanup_push/pthread_cleanup_pop cannot be used in C++ code or if compiling with the -fexceptions flag.
 * The RT library cannot be used without linking with NPTL. It means that you must always use -lpthread if using -lrt. Also -lc must not be used in the link command.