A new solution to improve the real-time performance of Embedded Linux

Source: Internet
Author: User
A new solution to improve the real-time performance of Embedded Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. Author: Cui Ke, Graduate School of Chinese Emy of sciences, Chen Wei, China University of Science and Technology
Improving the real-time performance of Embedded Linux is a hot topic in the field of embedded operating systems. Based on analyzing the real-time shortage of existing embedded operating systems, this paper proposes a new improvement solution (combining RTAI and uClinux) and provides specific industrial control application instances, further verify the functions of this system.



(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // tech.ccidnet.com/pub/attachment/2005/6/460807.gif'); ">
Dual-kernel real-time system embedded real-time Linux architecture


Embedded Linux is widely used because of its open code, low price, powerful functions, and ease of transplantation. It provides an attractive option for Embedded operating systems. However, many practical applications, such as multimedia communication, production process control, and online transaction processing, require responses to external events within a limited period of time. As a result, the real-time performance of embedded systems is getting more and more attention. Improving the real-time performance of Embedded Linux has become a hot topic in the field of embedded operating systems.

This paper proposes an embedded real-time operating system solution based on uClinux. The combination of RTAI and uClinux not only meets the requirements of embedded applications, but also ensures the hardware and timeliness of the system. In addition, there are powerful network functions, easy to upgrade, portability and other advantages. Finally, the application cases of the Remote Monitoring System for major equipment developed based on this operating system are combined to further verify its functions and performance.

Existing Problems in Embedded Operating System Applications

An excellent embedded operating system is the key to the success of the embedded system. In addition to the most basic functions of the general operating system, such as task scheduling, synchronization mechanism, interrupt processing, and file functions, it also needs to have the following features:

1. Better hardware adaptability, that is, good portability;

2. occupy less hardware resources;

3. High reliability;

4. provides powerful network functions and supports TCP/IP and other protocols;

5. Some applications require real-time performance.

The existing embedded operating systems can be divided into two categories: commercial and free. The commercial operating system provides sound technical support and after-sales services due to its stable and reliable functions, shares in the embedded market. However, it also has a series of problems, such as expensive, copyright required, and the source code is not open. The free operating system (such as Linux) source code is open and has a price advantage, however, there is still a lack of requirements for strictly meeting embedded real-time applications.


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // tech.ccidnet.com/pub/attachment/2005/6/460809.gif'); ">
Real-Time Kernel Implementation Mechanism


RTAI improves the real-time performance of Linux

There are several real-time system solutions for Linux. The implementation methods include:

1) directly modify the Linux kernel and increase real-time performance, for example, Montavista;

2) add real-time modules and dual-kernel structures on top of common linux kernels, such as RTLinux or RTAI.

Montavista can meet users' soft real-time requirements. RTLinux or RTAI focuses on enhancing Linux's hard real-time features. The time limit of a soft real-time system is flexible and flexible. It can tolerate occasional timeout errors. The failure does not cause serious consequences, but only slightly reduces the system throughput. A hard real-time system has a rigid and unchangeable time limit, which does not allow any errors that exceed the time limit. Timeout errors may cause damage or even system failure, or cause the system to fail to achieve its expected goals.

RTAI uses a dual-kernel method. Instead of directly using any Linux function, RTAI writes the work that requires high time precision into a driver, then, the driver is called directly using the interrupt generated by the PC time series chip. The biggest difference between RTAI and nmt rt-Linux is that it defines a set of real-time hardware abstraction layers (RTHAL) on Linux ). RTHAL defines the part of RTAI that needs to be modified in Linux as a set of program interfaces. RTAI only uses this set of interfaces to communicate with Linux. The advantage of doing so is that users can minimize the amount of effort to port RTHAL to the new Linux version by directly modifying the Linux core program code.

However, although RTAI meets the requirements of hard real-time performance, it is not small enough and suitable for embedded systems.

RTAI + uClinux real-time Solution

UClinux is designed for embedded applications and does not focus more on real-time issues. After Small transformation, uClinux has formed a highly optimized and compact embedded Linux, and retains most of the advantages of Linux. It specifically targets CPU without MMU and removes the Virtual Memory Management Section in the common Linux kernel. More importantly, uClinux provides a complete TCP/IP protocol stack and supports a large number of other network protocols, providing powerful network support for embedded systems.

From the previous analysis, we can see that RTAI is based on a common Linux kernel, which is too large compared with embedded applications. uClinux itself does not focus more on real-time issues. Therefore, the combination of RTAI and uClinux can adopt a dual-core design scheme, which not only meets the requirements of embedded applications, but also ensures the hardware and timeliness of the system.

1. Hardware Abstraction Layer


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // tech.ccidnet.com/pub/attachment/2005/6/460811.gif'); ">
System interrupt handling Flowchart


The implementation of the system is based on the hardware abstraction layer. Hardware Management is performed through the hardware abstraction layer to combine the basic kernel with the real-time kernel. The change of one kernel does not affect the execution of the other kernel.

The Hardware Abstraction Layer defines the abstract interfaces between the system and the hardware. It is mainly used to intercept hardware interruptions and redirect to basic or real-time tasks based on the requirements of the Real-Time Kernel scheduler. RTHAL contains a key component: the Interrupt Descriptor Table (IDT, Interrupt Descriptor Table), which defines a set of pointers for processing Interrupt routines. RTHAL itself defines a structure so that the basic kernel interrupt handler can be easily replaced by real-time handlers. In this way, after the real-time kernel is activated through RTHAL, the new IDT table is valid. Under the above control, the basic kernel serves as a task of the real-time system.

2. Dual-kernel structure

The overall structure model 1 of the dual-kernel real-time system mainly includes the basic kernel, real-time kernel, hardware abstraction layer, and hardware part.

The basic kernel (uClinux) and real-time kernel (RTAI) process the scheduling and execution of non-real-time and real-time tasks respectively, while the information exchange between real-time and non-real-time tasks must pass the pipeline (FIFO) or shared memory (MBUFF. When a real-time task is running, the basic kernel is blocked by the hardware abstraction layer. That is, the real-time kernel runs the basic kernel as a task with the lowest priority. It is scheduled only when no real-time task is run.

3. Real-Time Kernel Dynamic Loading

The real-time kernel of embedded real-time Linux is dynamically loaded. Before a real-time task is activated, the real-time kernel is not started. The basic kernel transparently accesses the hardware through RTHAL, just as RTHAL does not exist. When a real-time task is activated, the RTHAL structure changes, and the basic kernel is taken over by the real-time kernel, indicating that the system changes before and after the Real-Time Kernel starts.

4. Scheduling

When the interruption arrives, the real-time kernel determines whether it is a basic kernel interrupt or a real-time interrupt and processes it separately. If the basic kernel is interrupted, if a real-time task is currently running, only the interrupt flag is set. If no real-time task is running, the interrupt handler of the basic kernel is called; if the interrupt is a real-time interrupt, the corresponding real-time interrupt processing program is called directly. Note: Real-time interruption can lead the execution of basic kernel tasks. The system interrupt handling process is shown in step 3.

Application Cases

Industrial Control is a traditional application field of embedded real-time operating systems. It requires strict real-time processing functions, high reliability and good openness, and has special requirements on the development environment, operability, and cost. Therefore, this study uses the Remote Monitoring System of major equipment as one of its applications.

1. Embedded Remote Monitoring System Structure

Based on the remote monitoring of large equipment used in industrial production in the continuous operation status, this paper studies the embedded devices used for remote monitoring of major equipment. The system mainly includes the input/output module (NetIO) and the input/output module (NetWeb). The former is used to collect (input) field data ), or used for field device control (output). The latter integrates Web functions so that users can access the input/output modules over the Internet. The two modules are connected through the network. In this system, they are connected through the serial 485 bus. The embedded remote monitoring system structure 4 is shown in.

2. NetWeb function verification for Embedded Linux


(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // tech.ccidnet.com/pub/attachment/2005/6/460811.gif'); ">
Embedded Remote Monitoring Architecture


NetWeb is developed based on the embedded real-time Linux operating system described earlier. The special dual-Kernel Operating System structure determines the particularity of application development.

1) Task Management

Tasks in the system can be divided into real-time tasks and non-real-time tasks. real-time tasks include real-time data collection and processing. These functions must be implemented on the Real-Time Kernel RTAI. In addition, non-real-time tasks mainly include data storage and remote communication. These functions must be implemented on the basic kernel uClinux.

Embedded Real-Time Linux manages real-time and non-real-time tasks separately, and implements different scheduling policies and communication modes between tasks, communication between real-time tasks and non-real-time tasks can be achieved through real-time FIFO or shared memory. This function makes the application compilation concise and clear, with clear functions and flexible scheduling, facilitating users.

2) network functions

Embedded Real-Time Linux realizes the embedded Internet technology, and introduces Web servers to field testing and control devices. With the support of the corresponding hardware platforms and software systems, the transformation of traditional testing and control devices into an Internet-based network testing and control device with TCP/IP as the underlying communication protocol and Web technology as the core.

Compared with traditional Web applications, embedded Web simplifies the system structure and integrates information collection and information publishing into on-site measurement and control devices. With the Standard Interface Format and communication protocol, the Web server embedded in the device can provide a unified browser-based operation and control interface to any valid users accessing its network, the browser becomes the front-end control panel of the device.

3) Real-time

Embedded Real-Time Linux is a hardware real-time embedded operating system. When the interruption arrives, if the basic kernel is interrupted, if a real-time task is currently running, the interrupt flag is set to suspend the interruption. If the interruption is a real-time interruption, directly call the corresponding real-time interrupt processing program. This scheduling mechanism ensures that real-time tasks in the remote monitoring system are completed within a specified time limit, and provides powerful support for real-time prediction, diagnosis, and control of system faults.

In addition, the system also evaluates and verifies the functions of the operating system in terms of time management, memory management, interrupt management, synchronization, mutex management, and device management.

Summary

Although there are many ways to improve the embedded real-time performance of Linux, RTAI + uClinux has not yet seen any products. This solution not only meets the requirements of embedded systems, but also meets the hard real-time standards. It also has powerful network functions, easy to upgrade, portability, and other advantages.

At the same time, real-time tasks (based on RTAI) and non-real-time tasks (based on uClinux) are written separately for Application Programming on it, which is clear and concise. However, because users need to program directly in the kernel space, there are major risks from the perspective of system security. It is hoped that further discussions and research will improve it.

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.