Comparative Analysis of Embedded Operating Systems uC/OS and uClinux

Source: Internet
Author: User

Author: Lu Xixian, HUANG Tao, Zhu xianxin, Wuhan University of Technology

Abstract: an embedded operating system is the core software for embedded system applications. This article compares two typical open-source embedded operating systems, analyzes and summarizes several issues in embedded operating system applications, and summarizes the basis for selection of embedded operating systems.
Keywords: Embedded System Operating System uC/OS uClinux
Introduction
With the rapid development of modern computer technology and the wide application of Internet technology, the transition from the PC era to the 3C (computer, communication, and consumer electronics) era, represented by personal digital assistants, handheld PCs, and Information appliances. In the post-PC era, embedded systems play an increasingly important role and are widely used in Information appliances, mobile devices, network devices, industrial control simulation, and other fields.
Embedded systems are user-oriented, product-oriented, application-oriented, And customizable for hardware and software, it is applicable to computer systems that have strict requirements on functions, reliability, volume, cost, power consumption, and other features. With the extensive application of embedded systems, traditional front-end/back-end program development mechanisms cannot meet the increasingly complex and remembered implementation requirements, therefore, the real-time operation system (PROs) is often used in the field to develop real-time multi-task systems. Embedded real-time operating systems generally provide multi-task scheduling, time management, inter-task communication and synchronization, and memory management (memory)
Manager unit) and other important services, making embedded applications easy to design and expand. RTOS makes embedded products more reliable and has a shorter development cycle. RTOS has become a hot topic in embedded applications.
An embedded system that provides simple functions generally does not require an operating system. For example, in the past, a small system consisting of many MCS51 series single-chip microcomputer only used software to implement a simple control loop. However, with the advent of the so-called post-PC era, embedded system design becomes increasingly complex, embedded operating systems are essential.
Embedded RTOS has outstanding advantages in real-time system efficiency, hardware dependence, software solidification, and application professionalism. Generally speaking, an embedded operating system is different from a general computer operating system. It has the characteristics of low space occupation, high execution efficiency, convenient customization, and fixed storage required by software.
Since 1980s, some IT organizations and companies have started to develop commercial embedded operating systems and specialized operating systems. Some well-known embedded operating systems emerged, such as Microsoft's wince and WinDriver system's VxWorks, which are representative of Non-real-time and real-time embedded operating systems. However, the cost of commercial products is very expensive. for general purposes, the cost of commercial products will be increased and the competitiveness will be lost.
UC/OS and uClinux are free embedded operating systems with excellent performance, open source code, and widely used. They can be used as a model for studying real-time operating systems and non-real-time operating systems. This article analyzes and summarizes several important issues in embedded operating system applications by comparing uC/OS and uClinux, and summarizes the basis for selecting Operating Systems in embedded system development.
1 Introduction to two Open Source Embedded Operating Systems
The uC/OS and uClinux operating systems are currently widely used two Free and Open Source Embedded operating systems. UC/OS is suitable for small-sized control systems. It features high execution efficiency, small space occupation, excellent real-time performance, and high scalability. The minimum kernel can be converted to 2 kb. UClinux is an operating system that inherits the excellent features of standard Linux and is designed based on the characteristics of embedded processors. It has embedded network protocols and supports multiple file systems, developers can take advantage of the prior knowledge of standard Linux. After compilation, the target file can be controlled at several hundred kb.
UC/OS is a real-time operating system with free open source code, small structure, and real-time kernel deprivation. Its Kernel provides functions such as task scheduling and management, time management, synchronization and communication between tasks, memory management, and service interruption.
UClinux is an excellent embedded Linux version. UClinux is short for micro-conrol-Linux. Compared with standard Linux, it integrates the stability of standard Linux operating systems, powerful network functions, and excellent file systems. However, since there is no MMU (Memory Management Unit), the implementation of its multi-task requires some skills.
2 Comparison of main performance of two Embedded Operating Systems
The embedded operating system is the control center of the hardware and software resources of the embedded system. It organizes multiple users to share the various resources of the embedded system as reasonably and effectively as possible. The user refers to all the software above the system program. A reasonable and effective method refers to how the operating system coordinates and makes full use of hardware resources to achieve multi-task. Complex Operating Systems Support file systems to facilitate file organization and standardization.
Another feature of the embedded operating system is that the system is not directly available for different platforms. Generally, the operating system needs to be transplanted to the specialized platform to work normally.
Process scheduling, file system support, and system migration are the most common problems in embedded operating systems. The following describes the analysis and comparison of uC/OS and uClinux from these perspectives.
2.1 Process Scheduling
Task Scheduling is used to coordinate the competition for computer system resources (such as memory, I/O devices, and CPUs. Process Scheduling is also called CPU scheduling. Its fundamental task is to analyze the CPU of a ready process according to a certain principle. Because the memory and I/O devices in the embedded system generally belong to a process at the same time as the CPU, the concept of task scheduling is similar to that of process scheduling, which is not distinguished in many cases.
Process Scheduling can be divided into two basic methods: "Deprivation-type scheduling" and "non-deprivation-type scheduling. The so-called "non-deprivation-type scheduling" means that once a process is scheduled for execution, the process continues until the process ends, or because of a certain principle, the CPU is automatically abandoned and enters the waiting state, to re-allocate the CPU to other processes. The so-called "Deprivation-type scheduling" refers to: Once a process with a higher priority appears in the ready state, or the running process is full of the specified time slice, immediately deprive the current process of running (put it back to the ready state), and allocate the CPU to other processes.
As a real-time operating system, uC/OS uses a real-time, multi-task kernel that can be deprived. The deprived real-time kernel is running at any time with the highest priority. In uC/OS, a maximum of 64 tasks are supported, corresponding to priority 0 ~ 63, where 0 is the highest priority. Scheduling can be divided into two parts: finding the highest priority task and switching the task.
The highest priority task table. Each task in UC/OS has an independent stack space and a data structure called task control block (TCB, the first member variable is the saved Task Stack pointer. The task scheduling module first uses the variable ostcbhighrdy to record the TCB address of the current most advanced ready task, and then calls the OS _task_sw () function to switch the task.
UClinux process scheduling follows the Linux tradition. The system suspends a process at a certain time and generates a fast and periodic clock interruption. The scheduling function (timer processing function) is used to determine when a process has its time slice, then switch the process. This is achieved through the parent process calling the fork function to generate sub-processes.
After the fork call in uClinux is complete, either the child process is executed in place of the parent process (at this time, the parent process is dormant) until the child process calls exit to exit, or the exec is called to execute a new process, in this case, the executable file is loaded. Even if the process is only a copy of the parent process, this process is inevitable. After the child process executes exit or exec, the child process uses wakeup to wake up the parent process so that the parent process continues to run.
Since uClinux does not have MMU to manage memory, its access to memory is direct, and the addresses accessed in all programs are actually physical addresses. The operating system does not protect the memory space. Each process actually shares a runtime space. This requires data protection when multiple processes are implemented, and the space used by the user program may occupy the system kernel space. Pay more attention to these problems during programming; otherwise, the system may crash.
The above analysis shows that the uC/OS kernel is designed and implemented based on the requirements of real-time systems, which is relatively simple and can meet high real-time requirements; uClinux inherits the standard Linux multi-task implementation mode in terms of structure and only improves the features of embedded processors. To achieve real-time performance, the system must run under the control of the real-time kernel. RT-Linux is a real-time kernel that can implement this function.
2.2 File System
The so-called file system is the organization responsible for accessing and managing file information, it can also be said that it is the software part responsible for file establishment, revocation, organization, read/write, modification, replication, and management of the resources required for file management (such as Directory tables and storage media.
UC/OS is intended for small and medium-sized embedded systems. If all functions (semaphores, message mailboxes, message queues, and related functions) are included, the compiled uC/OS kernel is only 6 ~ 10 KB, so the system itself does not support the file system. However, uC/OS has excellent scalability. You can add the content of the file system as needed.
UClinux inherits the complete file system performance of Linux. It uses the romfs file system. This file system requires less space than the general ext2 file system. Space saving comes from two aspects: first, the kernel supports romfs file systems and requires less code than ext2 file systems. Second, the romfs file system is relatively simple, creating a file system superblock requires less storage space. The romfs file system does not support dynamic write/write operations. The system uses the virtual ramdisk method to process the data to be dynamically saved (the ramdisk uses the ext2 File System ).
UClinux also inherits the advantages of the Linux network operating system, which can easily support the Network File System and embed TCP/IP protocol. This facilitates the development of network access devices in uClinux.
From the support of the two operating systems for file systems, we can see that uClinux is a good choice in complicated embedded systems that require more file processing; however, uC/OS is mainly suitable for some control systems.
2.3 port operating system
The purpose of porting an embedded operating system is to instruct the operating system to run on a microprocessor or microcontroller. Both uC/OS and uClinux are open source code operating systems, and their structured design is easy to separate the processor-related parts. Therefore, it is possible to be transplanted to a new processor. The transplantation of the two systems is described below.
(1) transplantation of uC/OS
To port uC/OS, the target processor must meet the following requirements:
* The C compiler of the processor can generate reusable code and enable or disable interruptions in C;
* The processor supports interruption and can generate scheduled interruption;
* The processor supports enough RAM (several KB) as a task stack in a multi-task environment;
* The processor reads and stores the stack pointer and other CPU registers into the stack or memory.
After understanding the technical details of the processor and C compiler, you only need to modify the processor-related code for porting uC/OS. The specific content is as follows:
* Set a constant in OS _cpu.h to identify the growth direction of the stack;
* In OS _cpu.h, You need to declare several macros used for switch interruption and task switching;
* In OS _cpu.h, You need to redefine a series of data types for the specific processor's word length;
* OS _cpu_a.asm needs to rewrite functions in four assembly languages;
* OS _cpu_c.c needs to write 6 simple functions in C language;
* Modify the main header file include. h and add the preceding three files and other header files.
(2) porting uClinux
In fact, uClinux is a kind of improvement of Linux for embedded systems, and its structure is complicated. Compared with uC/OS, uClinux porting is much more complicated. In general, to port uClinux, the target processor should not only meet the preceding uC/OS requirements, but also have sufficient capacity (hundreds of kb or more) External ROM and ram.
The transplantation of uClinux can be roughly divided into three levels.
* Structure-level migration. If the structure of the processor to be transplanted is different from that of any supported processor, You need to modify the file of the processor structure under the Linux/arch directory. Although most of the uClinux kernel code is independent of the processor and its architecture, its lowest-level code is also specific to various systems. This is mainly manifested in their Interrupt Processing context, kernel ing maintenance, task context and initialization process are all unique. These routines are located in the lunux/ARCH/directory. Linux supports a wide variety of architecture, so for a new system, its low-level routines can imitate similar system routines.
* Platform-level migration. If the processor to be transplanted is a processor of a certain uClinux-supported system, you need to create a directory under the relevant architecture directory and write the corresponding code. For example, mc68ez328 is based on the m68k kernel without MMU. At this time, the Linux/ARCH/m68knommu/platform/mc68ez328 directory to be created is transplanted, and the tracking program is written under it (to implement the functions such as the interface from the user program to the kernel function) interrupt control scheduler and vector initialization program.
* Pole-level migration. If the processor is supported by uClinux, you only need to port it at the board level. Board-level porting requires Linux/ARCH /? Create a directory for the corresponding board in platform/, and then create the corresponding startup code crt0_rom.s or crt0_ram.s and the Link Description file Rom. LD or ram. lD. Board-level porting also includes writing drivers and setting environment variables.
Conclusion
The Comparison Between uC/OS and uClinux shows that the two operating systems have their own advantages and disadvantages in application. UC/OS occupies less space, has high execution efficiency, and has excellent real-time performance. It is relatively simple to transplant new processors. UClinux occupies a relatively large amount of space, and its real-time performance is average. Porting new processors is relatively complicated. However, uClinux has the ability to support a variety of file systems, embedded with the TCP/IP protocol, can learn from the rich resources of Linux, for some complex applications, uClinux has a considerable advantage. For example, Cisco 2500/3000/4000 routers are developed based on the uCLinux operating system. In short, the choice of the operating system is determined by the requirements of the embedded system. Simply put, a small control system can take full advantage of the Compact and real-time uC/OS advantages. If a complex system, such as a PDA and an Internet connection terminal, is developed, uClinux is a good choice.
(T113)

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.