Linux kernel porting-hyper-threading

Source: Internet
Author: User
This article analyzes Linux kernel porting-hyper-threading-general Linux technology-Linux programming and kernel information. The following is a detailed description. Application 2.6 kernel hyper-threading Mode

For most application software developers, most of the differences between Linux 2.4 and 2.6 kernel families have no direct impact on them. Most kernel changes only aim to improve system performance. But there are also exceptions. For some application software, kernel and system changes have a certain impact on their promotion and management of other processes and threads.

The 2.6 kernel provides users with a new and improved hyper-threading mode. This mode is implemented through NPTL (Native POSIX Thread Library. The adoption of the new hyper-threading mode has extraordinary significance for developers, system runtime libraries (such as the gnu c library), and shared application software libraries. This article will introduce basic hyper-threading concepts, discuss existing Linux hyper-threading modes, and highlight how to modify existing multi-threaded applications in the 2.6 kernel.

   Hyper-Threading Technology

In a multi-process operating system such as Linux, generating another process by one process is the most basic concept. The most typical example is a shell program, such as a Bash shell program. It is a standard Linux Command Interpreter. The shell program executes the corresponding application based on the user's command. It can start multiple commands directly and wait for them to complete. It can also execute multiple commands separately and simultaneously.

A process can usually call a group of fork () and exec () functions to generate a new process. The initial process calls the fork () function to generate a sub-process. The sub-process inherits the entire execution environment of the parent process. The fork () function calls the process ID (PID) of the sub-process to the parent process, and also includes the PID in the sub-process. Then, the child process uses the exec () function to call other commands and change the inherited execution environment. At the same time, the parent process can exit quickly or wait for the child process to return to its initial state.

   Linux hyper-threading Mode

The standard Linux hyperthreading library of all versions earlier than Linux 2.6 is called LinuxThreads. This library works with the gnu c library not lower than GLIBC 2.0 and is compatible with POSIX.

During the compilation of LinuxThreads and Native POSIX Thread Library (NPTL) source code, the main libraries generated are libpthread. so and libpthread.. Therefore, LinuxThreads and pthreads names can be used in the past. However, after NPTL is introduced, the two are easily confused. This article uses LinuxThreads and NPTL to clearly differentiate two hyperthreading libraries and their functions.

LinuxThreads has different performance, scalability, and availability limits. LinuxThreads uses a compiler to set the number of threads that can be generated by a single process. In addition, it uses a process manager to coordinate the relationships between all threads generated by each process. This will greatly increase the number of threads to establish and eliminate occupied resources. Although almost every thread has an independent process ID, signal processing is still completed in each process. For various reasons, during the implementation of LinuxThreads, the number of threads simultaneously generated and working is often limited. These factors include the asymmetry between the kernel and user space threads, lack of thread synchronization primitives required for Inter-thread communication and resource sharing.

Another hyperthread mode in Linux is IBM's next-generation POSIX thread (NGPT) project. It is an external hyperthreading library that works with the LinuxThreads suite. However, it can provide additional POSIX support and better performance than the standard LinuxThreads suite. The NGPT kit can be used in Linux2.4 and earlier kernels. Due to the generation of the new superthread mode, its application scope is getting smaller and smaller.

Since the emergence of the 2.5 kernel, NPTL has gradually replaced LinuxThreads and NGPT. NPTL provides high-performance hyper-threading support for Linux systems, basic features required by multi-threaded enterprise application software, and high-capacity, high-load network and mail servers. NPTL development is part of the 2.5 kernel development process and is integrated with Linux runtime components (such as GLIBC). NPTL with many advantages is the future development direction of Linux threads.

Some Linux system manufacturers (such as Red Hat) have begun to append NPTL to earlier versions of the kernel, and even use an environment variable to create a hyper-threading environment for specific optional processes. In systems that support this function, you can use the following command to set variables:
CODE: # export LD_ASSUME_KERNEL = 2.4.1
Related Article

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.