⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migrating to linux kernel 2_6 -- part 5 migrating apps to the 2_6 kernel and nptl.htm

📁 NPTL的使用是大势所趋
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                        you may notice changes in warning messages, code size, 
                        and changes to the options provided by the GCC compiler 
                        and the rest of the toolchain. It is especially 
                        important to be aware of the potential for increased 
                        code size when you are recompiling embedded 
                        applications. You may need to take advantage of 
                        additional or new optimization options in order to 
                        continue to fit your existing applications in 
                        resource-constrained environments. Newer versions of GCC 
                        are also increasingly conformant to various C and C++ 
                        specifications, and are therefore likely to complain 
                        about aspects of your application code that earlier 
                        versions of these compilers ignored. In general, new 
                        warnings from updated compilers should be seen as an 
                        opportunity to weed out latent defects.<BR><BR>Newer 
                        versions of GCC have also deprecated some 
                        machine-specific options (specified using -m) in favor 
                        of more general optimization options (specified using 
                        -f). This may require that you update values such as the 
                        CFLAGS options specified in application 
                        Makefiles.<BR><BR>Finally, newer versions of GCC 
                        implement optimizations that require them to notice 
                        possible alias situations that may have been ignored by 
                        earlier compilers. The aliasing issues can be resolved 
                        (at some performance cost) by using the no strict 
                        aliasing compiler option 
                        (<B>-fno-strict-aliasing</B>).<BR><BR><B>Updating 
                        Applications for NPTL</B><BR><BR>The changes between 
                        2.4's threading support and NPTL provide significant 
                        design and performance improvements. NPTL is far more 
                        compliant with the POSIX specification than the 
                        LinuxThreads package was under 2.4. NPTL also supports 
                        useful features such as mutexes that are shared among 
                        threads, simplifying resource sharing, conflict 
                        prevention, and increasing parallelism. Finally, NPTL is 
                        vastly more efficient than 2.4's threading support. Some 
                        of the standard performance metrics used at TimeSys have 
                        shown NPTL implementations to be up to three orders of 
                        magnitude faster than the same code using 
                        LinuxThreads.<BR><BR>Some of the more complex changes 
                        that you may have to make in your application logic when 
                        moving to NPTL are changes related to NPTL's improved 
                        support for POSIX signals and signal handling. 
                        LinuxThreads implemented generic Unix-style threads, but 
                        were limited by various implementation details. NPTL is 
                        a POSIX-compliant threading implementation, and 
                        therefore handles signals better both between processes 
                        and between all threads within those processes. With the 
                        NPTL, signals can now be sent from one thread to 
                        another, rather than simply on a per-process basis. 
                        Signals can also use arguments to transfer information 
                        from one thread to another.<BR><BR>Using the NPTL also 
                        requires that you make changes to existing code that 
                        needs to be able to uniquely identify specific threads. 
                        Under LinuxThreads, each thread had a unique process ID 
                        (PID). Each thread now shares the PID of its parent 
                        process, and the <B>getpid()</B> function therefore 
                        returns the same process ID for all threads in a 
                        process. With NPTL, a thread's Thread ID must be used to 
                        uniquely identify individual threads. <BR><BR>Changes to 
                        thread and process IDs also mean that the processes that 
                        are traditionally used to spawn processes must now be 
                        thread-aware. For example, the <B>exec()</B> functions 
                        are now thread-aware, so that a thread inherits the PID 
                        of its caller. However, any application that depended on 
                        having all threads survive an <B>exec()</B> will need 
                        some modification. The parent of a multi-threaded 
                        process is notified of a child's termination only when 
                        the entire process terminates. Thread-related changes 
                        have also been made to the behavior of related 
                        <B>fork()</B> calls. For example, functions registered 
                        with the <B>pthread_at_fork()</B> function are no longer 
                        run when a <B>vfork()</B> occurs.<BR><BR>In addition to 
                        changing the internals of thread identification, NPTL 
                        does away with the LinuxThreads notion of a manager 
                        thread, simplifying the process/thread relationship and 
                        eliminating what was essentially administrative overhead 
                        under LinuxThreads. This may require application changes 
                        if, for example, your application kept track of the 
                        number of threads running on its behalf or looked for 
                        the manager thread as a signal target.<BR><BR>Finally, 
                        using a new threading library means that certain 
                        threading functions that were available under 
                        LinuxThreads are no longer supported under the NPTL. For 
                        example, the <B>pthread_kill_other_threads_np()</B> 
                        function is no longer available. This function was used 
                        to simulate POSIX-conformant <B>exec()</B> functions. 
                        Since the <B>exec()</B> functions themselves are now 
                        POSIX conformant, the helper function is not 
                        necessary.<BR><BR>For additional information about the 
                        design and implementation of the NPTL, a general design 
                        and philosophy document is available <A 
                        href="http://people.redhat.com/drepper/nptl-design.pdf" 
                        target=new><U>here</U></A>.<BR><BR><B>Conclusion</B><BR><BR>Changing 
                        the kernel that your computer system runs is not 
                        necessarily an easy task, but is eminently doable. The 
                        white papers in this series have highlighted the issue 
                        in configuring the 2.6 kernel, updating device drivers, 
                        migrating desktop and custom systems, and updating 
                        applications. Certified 2.6-based distributions targeted 
                        for embedded use are already available from vendors such 
                        as TimeSys, whose 2.6 reference distribution was the 
                        first 2.6-based distribution for PPC systems. 
                        High-quality commercial software such as TimeSys 
                        TimeStorm IDE and TimeStorm Linux Developers Suite (LDS) 
                        is designed to help you migrate any Linux kernel, device 
                        driver, application, or deployed system to take 
                        advantage of the power of the 2.6 kernel and updated 
                        packages, threading methodology, and so on.<BR><BR>Linux 
                        is a shining example of the power of the Open Source 
                        movement as a positive force for change in the software 
                        industry. The Linux kernel, the core of any Linux 
                        distribution, is constantly evolving to incorporate new 
                        technologies and improve performance, scalability, 
                        support, and usability. The 2.6 kernel increases the 
                        spectrum of systems for which Linux is well-suited, from 
                        PDAs, process control systems, and set-top boxes all the 
                        way to enterprise servers. The cost, power, and 
                        supportability advantages by Linux are more obvious than 
                        ever in today's business market and fast-paced technical 
                        environment.<BR><BR>
                        <HR>

                        <CENTER><B>About the authors</B></CENTER>
                        <HR>
                        <BR><B>Peter Dibble</B>, TimeSys Distinguished Engineer, 
                        has more than twenty years of experience in system 
                        software, real-time operating systems, and development 
                        tools. He generated the first serious benchmark suite 
                        for worst-case performance of a commercial RTOS, led the 
                        technical design work for the first commercially 
                        successful software for digital set-top boxes, and was 
                        the senior technical resource for the first ports of 
                        Java and Personal Java to an embedded RTOS. Peter has 
                        served on the Real-Time POSIX working group and the 
                        Real-Time for Java Expert Group, and currently 
                        participates in the Real Time Specification for Java 
                        Technical Interpretation Committee. He has published 
                        widely including dozens of articles and conference 
                        papers and several books on topics relating to embedded 
                        and real-time systems, Java, power management, and 
                        general system software design and implementation. His 
                        latest book is "<CITE>Real-Time Java Platform 
                        Programming</CITE>" from Prentice Hall. He earned his 
                        Ph.D. in Computer Science from University of Rochester 
                        with a dissertation on a file system designed for NUMA 
                        multi-processors. <BR><BR><IMG hspace=10 
                        src="Migrating to Linux kernel 2_6 -- Part 5 Migrating apps to the 2_6 kernel and NPTL.files/wvhagen-80x110.jpg" 
                        align=left vspace=5><B>William von Hagen</B> is a Senior 
                        Product Manager at TimeSys Corp., has been a Unix 
                        devotee for over twenty years, and has been a Linux 
                        fanatic since the early 1990s. He has worked as a system 
                        administrator, writer, developer, systems programmer, 
                        drummer, and product and content manager. Bill is the 
                        author of <CITE>Linux Filesystems</CITE>, <CITE>Hacking 
                        the TiVo</CITE>, <CITE>SGML for Dummies</CITE>, 
                        <CITE>Installing Red Hat Linux 7</CITE>, and is the 
                        coauthor of <CITE>The Definitive Guide to GCC</CITE> 
                        (with Kurt Wall) and <CITE>The Mac OS X Power Users 
                        Guide</CITE> (with Brian Profitt). <CITE>Linux 
                        Filesystems</CITE> is available in English, Spanish, 
                        Polish, and traditional Chinese. Bill has also written 
                        for publications including <CITE>Linux Magazine, Mac 
                        Tech, Linux Format</CITE>, and online sites such as 
                        <CITE>Linux Planet</CITE> and <CITE>Linux Today</CITE>. 
                        An avid computer collector specializing in workstations, 
                        he owns more than 200 computer systems.<BR><BR>
                        <HR>
                        <A name=series></A>
                        <CENTER><B>Read the entire series . . .</B></CENTER>
                        <HR>
                        <BR>This article is part five of a series of whitepapers 
                        from TimeSys on Migrating to Linux kernel 2.6. The 
                        series includes:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -