Linux Kernel breakthroughs in embedded applications

Source: Internet
Author: User
Article Title: breakthroughs in embedded applications in the Linux kernel. 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.
As we all know, Linux has been widely used in embedded systems. To further promote this application, many functions that are very helpful to embedded applications are introduced in Linux 2.6. These new features include real-time performance enhancement, more convenient portability, support for large-capacity memory, support for improvements to microcontroller and I/O systems.
  
Embedded Computing usually involves computers of various sizes, including small handheld devices (such as watches and cameras) and distributed systems (such as communication switches) that contain thousands of nodes ). Embedded Systems may simply need only one small microcontroller, or use a large number of parallel processors and massive memory. The improvement of Linux 2.6 provides support for this series of requirements.
  
   Response time improvement
Embedded systems usually require a stable time limit. Although Linux 2.6 is not a real-time operating system, the improved response capability is more suitable for this field.
  
Before the 2.6 kernel, some special patches are required for Linux to provide better response capabilities. Generally, you need to purchase patches from the vendor to improve the interrupt performance and scheduling response time. Now, the 2.6 kernel has added these improvements to the mainstream kernel, so no special configuration is required.
  
Linux 2.6 provides some functions to improve the overall response capability. Two of the changes are worth noting. The first is the preemptible kernel, and the second is the more efficient scheduling algorithm.
  
   Preemptible Kernel
Like most other general operating systems, when a process is called by the system and running, the previous version of Linux does not allow the process to schedule. This means that once a task is being executed in a system call, the task will control the processor until the system call ends, regardless of the length of time it takes to use the processor. This design is much simpler, but in many cases it will lead to delays in the process of waiting for the completion of system calls.
  
Now, the kernel uses a preemption mode to some extent. Therefore, in some time-sensitive events, Linux 2.6 has better response capabilities than 2.4. Of course, it is not actually a real RTOS, but compared with the previous kernel, it feels much less "paused. In the Linux 2.6 kernel, the code is set to a preemption point, which means that the scheduler will stop a running process and execute a process with a higher priority. During system calling, Linux 2.6 regularly checks the preemption point to avoid unreasonable delays. During the check, the scheduling process may abort the current process to run another process.
  
The software with limited execution time is incompatible with the Virtual Memory Request page scheduling, because the disadvantage of processing slow pages in this method will damage the response capability of the program. The 2.6 kernel can be compiled into a system without virtual memory to eliminate this problem. Of course, this requires software designers to consider having enough real memory to run the application.
  
And displays the task response time of the 2.4.1 and 2.6 kernels in average and worst cases. Data comes from 3.1 million samples collected using a p iii 1.0GHz processor. The test uses a real-time test device with more than five interruptions of LynuxWorks. The system runs under a high load consisting of continuous disk data transmission, network communication, console input, image processing, and a timer card.
    
   Average Response Time
  
   Worst Response Time
   Efficient scheduling program
In version 2.6, the process scheduling was rewritten to remove the inefficient algorithms in previous versions. Previously, in order to determine which task to run next, the process scheduler had to check each ready task and determine which task was more important after calculation. After all calculations are completed, the task with the highest score will be selected. Because the time required for a large number of tasks in this algorithm is generally different, some complex multi-task applications often cannot be scheduled in a timely manner.
  
In the 2.6 kernel, the scheduler no longer scans all tasks each time, but puts a task into a queue named "current queue" when it becomes ready. When the process scheduler is running, it only selects the most favorable task in the queue for execution. In this way, scheduling can be completed at a constant time. When a task is executed, it gets a period of time, or gets the CPU usage right for a period of time before it is transferred to another thread. After the time period is used up, the task is moved to another queue named "expired. In this queue, tasks are sorted based on their priorities.
  
In a sense, all tasks in the current queue will be executed and moved to the "expired" queue. When this happens, the situation changes, the queue will be switched, the original "expired" queue will become the current queue, and the empty current queue will become the expired queue. Because the tasks in the new current queue have been arranged, the scheduler can now use a simple queue algorithm, that is, it always takes the first task in the current queue for execution. Regardless of the number of tasks, this new process is actually much faster than the old one.
  
   New synchronization measures
Multi-process applications sometimes need to share some resources, such as shared memory or devices. To avoid competition, programmers use a function named mutex to ensure that only one task is using resources at a time. So far, Linux has implemented mutex through a system call included in the kernel, and the system call determines whether a thread is waiting or continuing to execute. However, this time-consuming system call is not required when you decide to continue execution. The Linux 2.6 kernel supports the so-called FUSM (Fast User-Space Mutex ). This new function checks the user's space to see if there is any waiting condition, and calls the system only when the thread needs to wait. When the waiting time is not needed, it will avoid unnecessary system calls to save time. This function also uses Priority Scheduling to determine which thread can be executed in the event of competition.
  
   Improved shared memory
An embedded system is sometimes a device with many processors, such as in a telecom network or a large storage system. Whether it is a balanced or loosely connected multi-processor, it is generally shared memory. Balanced Multi-process design means that all processors have equal access to memory, and the decisive factor limiting memory usage is the efficiency of processes. Linux 2.6 provides a different way for multi-programs, called NUMA (Non Uniform Memory Access ). In this method, the memory and the processor are connected to each other, but for each processor, some memory is "disabled", and some memory is "Farther. This means that when memory competition arises, the "closer" processor has a higher right to use the nearest memory. 2.6 The Kernel provides a set of functions to define the topological relationship between the memory and the processor. The scheduler can use this information to allocate local memory for the task. This reduces the bottleneck caused by memory competition and increases the throughput.
  
   POSIX Threads, signals, and timers
The POSIX standard describes a set of functions used to create and manage POSIX Threads. These well-defined system functions can be used in previous Linux versions, but they have been greatly improved in the 2.6 kernel. In comparison, NPTL (Native POSIX Thread Library) has improved significantly, and even exceeds the high-performance options available in some patches.
  
Along with POSIX Threads, 2.6 makes POSIX signals and POSIX high-precision timers an integral part of mainstream kernels. The POSIX signal is greatly improved compared with the Unix mode signal used in previous Linux versions. New POSIX signals cannot be lost and can carry information as parameters. In addition, POSIX signals can also be transmitted from one POSIX thread to another, rather than from one process to another like Unix signals.
  
Embedded systems usually require hardware to run tasks at a fixed time. The POSIX Timer allows any task to periodically get the scheduled time. The timer clock can achieve high accuracy, so that software engineers can control task scheduling more accurately.
  
   Supports General Design
In the embedded world, hardware design is usually customized to meet specific applications. Therefore, designers often need to use the original method to solve design problems. For example, boards manufactured for specific purposes may use different IRQ managers rather than similar designs. To be able to run on a new motherboard, Linux needs to change (migrate) to support new hardware. If the operating system is composed of independent components, this change should be simple, because you only need to change the code that needs to be changed. In the 2.6 kernel, a sub-framework concept is introduced. In the new definition, components are clearly separated and can be changed or replaced independently, without affecting other components or software packages or affecting them very little.
  
   Device, bus, and I/O
Now Linux is becoming the first choice for industry users. The 2.6 kernel contains ALSA (Advanced Linux Sound Architecture), which securely uses USB and MIDI devices. By using ALSA, the system can play and record audio simultaneously.
  
The Video4Linux system used to support videos has also taken a new look in 2.6. Although not backward compatible, it can be used for the latest broadcast, TV, digital camera and other multimedia.
  
Linux 2.6 uses USB 2.0, which is 40 times faster than general USB. It is foreseeable that in the near future, high-speed devices will become very popular, while Linux is a pioneer in USB 2.0 support.
  
   Support for 64-bit Processors
In some embedded systems, computers need to provide a lot of resources, such as large memory and multi-processor with high throughput. These large systems have a large number of embedded applications, such as large-scale storage systems and special computing engines.
  
With the 2.6 kernel, a 64-bit processor can be selected for Embedded Linux developers who require a large amount of memory. Intel anteng 64-bit processors have been supported in earlier Linux versions. In the new version, they include the AMD64 architecture and begin to provide support for AMD Opteron processors. Of course, PowerPC is not ignored, and PPC64 is now supported. Obviously, the Linux community is passionate about the innovation of large-capacity bus and large-capacity memory computing.
  
   Support for Microcontroller
Currently, the mainstream Linux 2.6 kernel also provides support for micro-processing controllers. Previously, Linux needed a full-featured microprocessor with memory management in most cases. However, in the embedded market, simpler controllers are more suitable for low-cost and simple applications.
  
Linux's micro-control project has become a very important branch of Linux for small systems. The branch named uClinux has received wide attention from developers of small processors. In version 2.6, a very important part of uClinux is integrated

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.