Research on Embedded Real-time Operating System Based on Linux

Publisher:Xiaoxue666Latest update time:2013-05-26 Keywords:Linux Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Introduction

  Since the 1980s, a variety of commercial embedded operating systems have emerged. Most of these operating systems are developed for special or general systems, such as VxWorks, Windows CE, pSOS, Palm OS, OS-9, LynxOS, QNX, LYNX, etc. Their advantages are that they provide users with a good development environment, improve the development efficiency of application systems, have high operating efficiency and good real-time performance, but their disadvantages are that they are expensive and the source code is closed. This not only affects the enthusiasm of developers, but also causes the cost of the entire product to rise sharply. [1]

  In view of the actual domestic situation, what the embedded system needs is a real-time operating system that is highly concise, user-friendly, reliable, widely used, easy to develop, multi-tasking, and low-cost.

  In the development of embedded products, it is necessary to find a cheap embedded real-time operating system to reduce product development costs and system complexity. Due to the many advantages of Linux, it is a practical issue to explore whether Linux can be properly modified as a cheap embedded real-time operating system.

  2. Features of Linux

  Linux is a network operating system that is born with maturity and stability. Linux is open source software, and there is no black box technology. Anyone can modify it or use it to develop their own products. The Linux system can be customized, and the system kernel can now be made very small. A core program with a Chinese system and a graphical interface can be less than 1MB and is equally stable. As a scalable software platform system, Linux is an excellent resource for the development of embedded products, and many Linux enthusiasts around the world can provide strong technical support to Linux developers. Therefore, Linux is a very promising choice as a low-cost embedded real-time operating system. [2] [3]

  (1) Close integration with hardware chips

  One of the main features of embedded Linux is its close integration with hardware chips (such as SOC, etc.). It is not a pure software Linux system, but is closer to hardware than general operating systems. With the further development of embedded Linux, it gradually possesses all the characteristics of embedded RTOS: real-time performance and close integration with embedded processors.

  (2) Open source code

  Another major feature of embedded Linux is the openness of the code. The openness of the code is adapted to the diversity of smart devices in the post-PC era. The openness of the code is mainly reflected in the availability of source code. Linux code development is like "market-style" development, where you can choose and integrate new products as you wish.

  For embedded Linux, the BIOS layer functions are actually implemented in the Linux driver layer. At present, in the Linux field, there are free software BIOS codes specially customized for the Linux operating system, and such BIOS layer functions are implemented on many motherboards.

  3. Implementation mechanism of RT-Linux

  RT-Linux transforms the Linux kernel and makes some changes to the Linux kernel working environment, as shown in Figure 1:

  

  As can be seen from the figure above, an RT-Linux kernel control is added to the Linux kernel and hardware interrupts. Linux control signals must be sent to the RT-Linux kernel for processing first. A virtual interrupt mechanism is implemented in the RT-Linux kernel. Linux itself can never block interrupts. The interrupt blocking signal and interrupt opening signal it sends are modified to send a signal to RT-Linux. For example, in Linux, the "sti" and "cli" macro instructions are used to block and enable interrupts by sending an instruction to the x86 processor, and RT-Linux modifies these macro instructions so that only some marks in RT-Linux are modified. All interrupts are divided into two categories: Linux interrupts and real-time interrupts. If the interrupt signal received by the RT-Linux kernel is a normal Linux interrupt, a flag bit is set; if it is a real-time interrupt, the interrupt continues to be sent to the hardware. After executing sti in RT Linux to turn on the interrupt, those Linux interrupts indicated by the set flag bit continue to execute. Therefore, cli cannot prohibit the operation of the RT Linux kernel, but can be used to interrupt Linux. Linux cannot interrupt itself, but RT-Linux can.

  The design principle of RT-Linux is to do as little work as possible in the real-time kernel module. If it can be done in Linux without affecting the real-time performance, it should be done in Linux. Therefore, the RTLinux kernel is made as simple as possible. In the RT-Linux kernel, there is no need to wait for resources, and there is no need to use shared spin locks (SpinLock). The communication between real-time tasks and Linux processes is also non-blocking, and there is no need to wait for data to enter or exit the queue.

  RT-Linux delegates the initialization of the system and devices to Linux, and also delegates the application and allocation of dynamic resources to Linux. RT-Linux uses statically allocated memory to complete hard real-time tasks, because when there are no memory resources, the blocked threads cannot have hard real-time capabilities.

  4. Change the Linux kernel architecture

  The Linux kernel system adopts Monolithic. In this architecture, all parts of the kernel are concentrated together, and all components are compiled and linked together. Although this allows the various parts of the system to communicate directly, effectively shortens the switching time between tasks, improves the system's response speed, has good real-time performance and improves CPU utilization, but when the system is large, the volume is also large, which does not conform to the characteristics of embedded systems with small capacity and limited resources. Another kernel architecture, MicroKernel, only includes some basic kernel functions such as creating and deleting tasks, task scheduling, memory management and interrupt processing in the kernel, while the file system, network protocol stack and other parts are all running in the user memory space. Although this structure is not as efficient as the Monolithic kernel, it greatly reduces the size of the kernel and greatly facilitates the upgrade, maintenance and transplantation of the entire system, so it can better meet the characteristics of embedded systems. Therefore, in order to make the application of embedded Linux more extensive, it is possible to consider transforming some structures in the current Monolithic kernel structure of Linux into the MicroKernel architecture. Through this compromise, the resulting Linux can have both good real-time performance and meet the requirements of small size of embedded systems.
5. RT-Linux programming interface (API) and programming method examples

  (1) RTLinux programming and control interface (API).

  By using the RTLinux programming and control interface (API), you can provide functions such as creating and deleting real-time tasks, scheduling and controlling tasks, etc. The API functions are mainly divided into the following categories:

  1) Interrupt control API function; 2) Clock control and acquisition; 3) Thread creation and deletion; 4) POSIX driver interface; 5) FIFO device driver; 6) Serial port driver API function; 7) mbuff driver API function; 8) Floating point operation API function.

  (2) RTLinux programming method example

  The principle of this program is to measure how much time is needed to schedule real-time tasks in RT-Linux. The algorithm is as follows:

  /*Real-time task side*/

  For every 500 cycles

  Waiting for the task of the previous cycle to complete

  Get the difference between the current time and the last periodic task completion time, which is the scheduling time

  cycle

  Output the maximum and minimum values ​​completed in 500 cycles to the FIFO.

  /*Application side*/

  Read the FIFO device and get the maximum and minimum values

  Print it on the screen

  This programming method is a common method for RT Linux programming. It divides a task into a real-time part and a non-real-time part. The real-time part completes the real-time task, while the non-real-time part mainly completes functions such as display that do not require real-time. The system structure of the program is as follows:

  

  Due to limited space, the program code is omitted.

  6. Several issues in developing embedded RT-Linux

  (1) Linux porting: If Linux does not support the selected platform, the part of the Linux kernel related to the hardware platform needs to be rewritten to support the selected platform.

  (2) Kernel trimming: Embedded products have fewer available resources, so their kernels are a bit large compared to embedded systems and need to be trimmed to a usable size.

  (3) Desktop system. A modern operating system is not convincing without a friendly interface. The current desktop Linux system uses the traditional X-Window system model - Client/Server structure. The hardware-related part is the server side, which implements a standard display interface; the application realizes the display of the program by requesting the server's service. On top of this, the window management function is implemented. However, X Window is too large for embedded systems. Currently, there is MiniGUI in China and MicroWindow abroad, both of which are committed to the development of embedded Linux GUI. Work on X-Window for embedded Linux is also in progress.

  (4) Driver development. The Linux kernel is updated very quickly, and many of the latest hardware drivers are quickly supported. However, the application fields of embedded systems are diverse, and the hardware devices used are also different. It is impossible for all of them to have Linux drivers. Therefore, the development of device drivers is also an important task.

  7. Conclusion

  The development of embedded systems is a process of combining tailoring and transplantation, and developers do not write much code themselves. In the design of the intelligent traffic monitoring system, the author selected RT-linux as the system development platform through appropriate tailoring of Linux, which has achieved good results in improving the system development efficiency and reducing the development cost. Of course, the development of embedded systems has put forward higher requirements for embedded operating systems. Therefore, in-depth research on the structure, design, user interface and many other aspects of embedded operating systems will contribute to the application and development of embedded systems.

Keywords:Linux Reference address:Research on Embedded Real-time Operating System Based on Linux

Previous article:Smart home routing system based on ARM
Next article:In-depth analysis of the latest three series of MIPS Aptiv

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号