Article Title: Ubuntu --- NativePOSIX thread library. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Linux kernels released earlier than version 2.6, the Linux thread library is called LinuxThreads, which is supported by the gnu c library after glibc2.0. Although the library uses the posix api, it does not really follow the POSIX standard. From the 2.6 kernel, Linux introduced NPTL. It is much better than LinuxThreads in terms of performance and complies with POSIX standards. However, using only the 2.6 kernel does not mean using NPTL. Although some releases carry both NPTL and LinuxThreads, all modern Linux releases carry NPTL by default.
Run the following command to view the POSIX implementation in use on your system:
Note that the content to be translated in this Code is as follows:
(1) "This was returned from SUSE 9.1 installation" is translated as "This is the result returned by SUSE 9.1"
(2) "This was returned from Fedora 2.6.9-1.667 Instatllation" is translated into "This is the result returned by Fedora 2.6.9-1.667"
(3) "This was returned from an old RedHat installation" "is translated as" This is the result returned by an old version of RedHat"
$ Getconf GNU_LIBPATHREAD_VERSION
$ Getconf GNU_LIBPATHREAD_VERSION
$ Getconf GNU_LIBPATHREAD_VERSION
You can use the following method to check which compilation tool is used for the Linux release to compile the link.
Find the libpthreads library linked to/bin/ls, as follows:
(CODE) (P81 countdown to 14th rows)
$ Ldd/bin/ls | grep libc. so.6
From the above output, we can see that libc. so.6 is linked with "Native POSIX Threads Library by Ulrich Drepper.
NPTL implements a one-to-one thread model. That is, a user thread corresponds to a kernel thread. NPTL also implements the synchronization primitives between POSIX processes, and the thread option PTHREAD_PROCESS_SHARED is also explicitly supported.
3.9.1 maximum number of threads
On Linux, the maximum number of threads that an application can create is different for different releases. SUSE9.1 running on 2 CPUs and 2 GB memory allows 16317 threads to be created before pthread_create returns an EAGAIN error. An EAGAIN error indicates that the application may exceed certain system limits. The stack size of the application creation thread is 16384, which is the maximum stack size allowed when the thread is created. Before setting the stack size to 16384, the application fails to create 1,021st threads and returns the error code ENOMEM. In any case, 8000 to 16000 threads are sufficient to meet the needs of any application.
To create a large number of threads in Linux, do the following:
1. Create the correct stack size (note 17 );
2. Check the ulimit (a tool that can output memory and stack size restrictions) and modify the corresponding item or edit the/etc/security/limits. conf file.
Chapter 5, Chapter 6 details the content of POSIX Threads and their differences with NPTL.
[1] [2] [3] [4] Next page