With the rapid development of modern computer technology and the wide application of Internet technology, the transition from the PC era to 3c, represented by personal digital assistants, handheld PCs, and Information Appliances
Sub-systems) integrated post-PC era. In the post-PC era, embedded systems play an increasingly important role and are widely used in Information appliances, mobile computer devices, network devices, industrial control simulation, and other fields. Embedded System
Development has also become a technical hotspot in the IT industry in recent years.
Embedded Systems that complete simple functions generally do not require an operating system. For example, a small system consisting of many M cs51 series single-chip microcomputer only uses software to implement a simple control loop. However, with the advent of the Post-PC era, embedded system design becomes increasingly complex and embedded operating systems are essential.
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 systems and specialized operating systems. Some well-known embedded systems, such as Microsoft
Division's
The VxWorks of wince and windriversystem are representative of Non-real-time and real-time embedded operating systems. However, commercial products are expensive and generally used
This will increase the cost of products and lead to loss of competitiveness.
The uC/OS and uClinux operating systems are two free embedded operating systems with excellent performance and open source code, which can be used as a model for studying real-time operating systems and non-real-time operating systems. This article
By comparing uC/OS and uClinux, this paper analyzes and summarizes several important issues in embedded operating system applications, and summarizes the basis for selecting Operating Systems in embedded system development. 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 control systems with high execution efficiency and space occupation.
Small, excellent real-time performance, strong scalability, etc. The minimum kernel can be translated to 2 K. UClinux inherits standard Linux
This is an operating system designed for 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. Its post-compilation goal
Files can be controlled at hundreds of 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 Standard
Linux operating system stability, powerful network functions, excellent file system and other main advantages. However, since there is no MMU (Memory Management Unit), the implementation of its multi-task requires some skills.
Comparison of the main performance of the 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 on 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 the practical application of embedded operating systems. The following describes the analysis and comparison of uC/OS and uClinux.
Process Scheduling
Ren
Scheduling is mainly used to coordinate tasks to compete for resources (such as memory, I/O devices, and CPUs) in computer systems. Process Scheduling is also called CPU scheduling. Its basic task is in the ready state according to some principle.
Process allocation CPU. 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.
A task is actually a process.
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 is completed.
Or, for some reason, discard the CPU and enter the waiting state to re-allocate the CPU to other processes. The so-called "Deprivation-type scheduling" refers to a process with a higher priority in the ready state or running
When the specified time slice is used, the current process is immediately deprived of running (put it back to the ready state), and the CPU is allocated to other processes.
As a real-time operating system, uC/OS uses a real-time, multi-task kernel that is denied. The deprived real-time kernel is running at any time with the highest priority. UC/OS supports a maximum
64 tasks with a priority of 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 most important task is to create a ready task table. Each task in UC/OS has an independent stack space, and a TCB (Task
Control Block) data structure, where the first member variable is the saved Task Stack pointer. The task scheduling module first uses variables
Ostcbhighrdy records the TCB address of the current most advanced ready task, and then calls the OS _task_sw () function to switch the task.
The process scheduling in uClinux follows the tradition of Linux. The system suspends the process at a certain time, and the system generates fast and periodic clock interruptions.
Determines when a process has its time slice. Then perform the relevant process switchover, which is achieved by the parent process calling the fork function to generate sub-processes.
UClinux
After the system fork call is complete, either the child process is executed in place of the parent process (at this time, the parent process has
Sleep), until the sub-process calls exit to exit; or call exec to execute a new process, which generates executable file loading, even if the process is only a copy of the parent process, this process
It 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 team's memory space is not protected, and each process is actually
To share 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, it is easy
Cause system 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. While uClinux inherits the standard structure
Linux's multi-task implementation method is improved only for the characteristics of embedded processors. To achieve real-time performance, the system needs to run under the control of the real-time kernel. RT-Linux can achieve this
A Real-time kernel of a function.
File System
The so-called file system refers to 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 it contains all the functions (semaphores, message mailboxes, message queues, and related functions), 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, which requires less space than the general ext2 file system. Space
The cost savings come from two aspects. First, the kernel supports romfs file system and requires less code than ext2 file system. Secondly, the romfs file system is relatively simple, and the file system is a super block.
(Superblock) requires less storage space. The romfs file system does not support dynamic write/Erase storage. The system uses a virtual ramdisk to process data that needs to be dynamically stored.
(The ramdisk will use 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 the TCP/IP protocol, which facilitates the development of network access devices in uClinux.
According to the support of the two operating systems for the file system, uClinux is a good choice in complicated embedded systems that require more file processing. However, uC/OS is mainly suitable for some control systems.
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 transplant uC/OS, the target processor must meet the following requirements;
· The C compiler of the processor can generate reusable code and enable and disable interruptions in C language;
· The processor supports interruption and can generate scheduled interruption;
· The processor supports enough RAM (several K bytes) 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:
· In OS _ CPU. H, you need to set a constant to identify the growth direction of the stack;
· In OS _ CPU. H, several macros need to be declared for switching interruptions and task switching;
· In OS _ CPU. H, you need to redefine a series of data types based on the processor's word length;
· OS _ cpu_a.asm needs to rewrite functions in four assembly languages;
· OS _ cpu_c.c requires six simple functions written in C language;
· Modify the main header file include. h and add the preceding three files and other header files.
(2) porting uClinux
Because uClinux is an improvement of Linux for embedded systems, its structure is complex and
The migration of uC/OS and uClinux is much more complicated. In general, to transplant uClinux, the target processor must 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 divided into three levels:
· Structure-level transplantation: 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, but its lowest-level code is specific to various systems. This is mainly manifested in their Interrupt Processing context, memory ing
The maintenance, task context, and initialization process are unique. These routines are located in the Linux/ARCH/directory. Because Linux supports a wide variety of architectures
System, its low-level routines can imitate the system routine writing similar to it.
· Platform-level transplantation: If the processor to be transplanted is a branch processor of a certain uClinux support system, you need to create a directory under the relevant architecture directory and write the relevant code. For example
Mc68ez328 is based on the m68k kernel without MMU. In this case, you need to create Linux/ARCH/m68knommu/platform/
In the mc68ez328 directory, write the Tracking Program (to implement the user program to the kernel function interface and other functions), interrupt control scheduling program and vector initialization program.
· Board-level porting: If your processor is supported by uClinux, you only need to port it. Board-level porting requires Linux/ARCH /? Create a phase in platform/
And then create the corresponding startup code crt0_rom.s or crt0_ram.s and Link Description file Rom. LD or ram. lD. Board-level porting also includes
Write the driver and set environment variables.
Conclusion
By comparing the uC/OS and uClinux, we can see that the two operating systems have their own advantages and disadvantages in application.
UC/OS occupies less space, has high execution efficiency, excellent real-time performance, and is relatively simple for porting new processors. UClinux occupies a relatively large amount of space, and its real-time performance is average.
Relatively complex. However, uClinux supports a variety of file systems and is embedded with TCP/IP protocols. You can learn from the rich resources of Linux and perform complex operations.
UClinux has considerable advantages. 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.
UClinux is a good choice for complicated systems such as terminals.