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. Figure 1 dual-core 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. Figure 2 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 Figure 3 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. Figure 2 shows the system changes before and after the real-time kernel is started. 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 Figure 4 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. |