Ubuntu --- NativePOSIX thread Library

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.