The difference between ucos and uclinux and their characteristics

uc/os and uclinux operating systems are two kinds of free embedded operating systems with good performance and open source code and widely used. They can be used as models for studying real-time operating systems and non-real-time operating systems. By comparing uc/os and uclinux, this paper analyzes and summarizes several important problems in the application of embedded operating systems, and summarizes the basis for selecting the operating system in the development of embedded systems. Two open source embedded operating systems introduce uc/os and uclinux operating systems, which are two free and open source embedded operating systems that are currently widely used. uc/os is suitable for small control systems and has the characteristics of high execution efficiency, small footprint, excellent real-time performance and strong scalability. The minimum kernel can be compiled to 2k. uclinux is an operating system that inherits the excellent features of standard linux and is designed according to the characteristics of embedded processors. The compiled object file can be controlled in the order of hundreds of k. uc/os is a free open source, compact, real-time operating system with a deprivable real-time kernel. Its kernel provides functions such as task scheduling and management, time management, synchronization and communication between tasks, memory management and interrupt service.
uclinux is an excellent embedded linux version. uclinux is short for micro-conrol-linux. Compared with standard linux, it integrates the main advantages of the standard linux operating system, such as stability, powerful network function and excellent file system. But since there is no mmu (memory management unit), the realization of its multitasking requires certain skills. The main performance comparison of the two embedded operating systems The embedded operating system is the control center of the software and hardware resources of the embedded system. It organizes multiple users to share various resources of the embedded system in a reasonable and effective way. The user refers to all the software above the system program. The so-called reasonable and effective method refers to how the operating system coordinates and makes full use of hardware resources to
achieve multitasking. Complex operating systems support file systems, which facilitate the organization and normalization of files. Another feature of the embedded operating system is that for different platforms, the system is not directly available, and generally requires a transplanted operating system for a special platform to work normally. Process scheduling, file system support and system porting are the most common problems in practical applications of embedded operating systems.
Question, the following will analyze and compare uc/os and uclinux from these perspectives.
Process scheduling Task scheduling is mainly to coordinate the competition and use of resources (such as memory, i/o devices, and cpu) in the computer system. Process scheduling is also known as cpu scheduling, and its fundamental task is to allocate cpu to processes in the ready state according to certain principles. Since memory and i/o devices in embedded systems generally belong to a process at the same time as cpu, the concepts of task scheduling and process scheduling are similar, and they are not distinguished in many occasions. The tasks mentioned below are actually the concept of processes.
Process scheduling can be divided into two basic methods: "preemptive scheduling" and "non-preemptive scheduling". The so-called "non-preemptive scheduling" means that once a process is scheduled for execution, the process will continue to execute until the process ends,
or the CPU will be reassigned to other processes by giving up the CPU for some reason and entering the waiting state. The so-called "preemptive scheduling" refers to: once a process with a higher priority appears in the ready state, or a running process
When the process has used up the specified time slice, it will 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 is a preemptive real-time multitasking kernel. A preemptive real-time kernel runs the highest-priority task that is ready at all times. Up to 64 tasks can be supported in uc/os, corresponding to priority 0"63, of which 0 is the highest priority. The content of the scheduling work can be divided into two parts: the search for the highest priority task and the task switching. Its highest priority The search for tasks is achieved by establishing a ready task table. Each task in uc/os has an independent stack space and a data structure called task control block tcb (task control block), in which the first member The variable is the stored task stack pointer. The task scheduling module first uses the variable ostcbhighrdy to record the tcb address of the current highest-level ready task, and then calls the os_task_sw() function to perform task switching. The process scheduling of uclinux follows the tradition of linux. Time suspends the process, while the system generates fast and periodic clock timing interrupts, and determines when the process has its time slice through the scheduling function (timer processing function). Then perform related process switching, which is called fork by the parent process The function is implemented by generating a child process. After the fork call of the uclinux system is completed, either the child process executes instead of the parent process (the parent process has already
sleep at this time), until the child process calls exit to exit; or calls exec to execute a new process, this time generates The loading of the executable file, even if the process is only a copy of the parent process, this process is inevitable. When 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 execute.
Because uclinux does not have mmu management memory, its access to memory is direct, and the addresses accessed in all programs are actual physical addresses. The operating system's memory space is not protected, and each process actually shares a running space. This requires data protection when implementing multiple processes, and also leads to the fact that the space used by the user program may occupy the system kernel space. These problems need to be paid more attention when programming, otherwise the system may crash easily. It can be known from the above analysis that the uc/os kernel is designed and implemented according to the requirements of the real-time system, which is relatively simple and can meet the higher real-time requirements. And uclinux inherits the multitasking implementation of standard linux in structure, and only improves it for the characteristics of embedded processors. To realize the real-time effect, the system needs to run under the control of the real-time kernel, and rt-linux is a real-time kernel that can realize this function.

File system The so-called file system refers to the organization responsible for accessing and managing file information. media, etc.) implement the management software part. uc/os is for small and medium embedded systems. If it includes all functions (semaphore, message mailbox, message queue and related functions), the compiled uc/os kernel is only 6"10kb, so the system itself does
not System support. However, uc/os has good expansion performance, and if necessary, you can add the content of the file system by yourself.
uclinux inherits the perfect file system performance of linux. It uses the romfs file system, which requires less space than the general ext2 file system. The space saving comes from two aspects. First, the kernel requires less code to support the romfs file system than to support the ext2 file system. Second, the romfs file system is relatively simple and requires less storage space to create a file system superblock. The romfs file system does not support dynamic erasing and saving. For the data that the system needs to dynamically save, the virtual ram disk method is used for processing (the ram disk 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 provides convenience for uclinux to develop network access devices. From the support of the two operating systems to the file system, uclinux is a good choice in the complex embedded system that needs more file processing. And uc/os is mainly suitable for some control systems. The transplant of the operating system The purpose of the transplant of the embedded operating system is to make the operating system run on a certain microprocessor or microcontroller. Both uc/os and uclinux are operating systems with open source code, and their structural design facilitates the separation of processor-related parts, so it is possible to be ported to new processors. The following describes the migration of the two systems respectively.
(1) Migration of uc/os To transplant uc/os, the target processor must meet the following requirements; The processor's c compiler can generate reentrant code, and interrupts can be turned on and off in C language;
The processor Support interrupts, and can generate timed interrupts;
The processor supports enough ram (several k bytes) as a task stack in a multitasking environment;
The processor has the ability to read and store the stack pointer and other cpu registers to the stack or instructions in memory.
After understanding the technical details of the processor and the c compiler, the porting of uc/os only needs to modify
the code related to the processor. The specific contents are as follows:
· A constant needs to be set in os_cpu.h to identify the stack growth direction;
os_cpu.h needs to declare several macros for switching interrupts and task switching;
os_cpu.h needs to redefine a series of data types according to the word length of the specific processor;
os_cpu_a.asm needs to rewrite 4 assembly language Functions;
·os_cpu_c.c needs to write 6 simple functions in C language;
·Modify the main header file include.h, add the above three files and other own header files.
(2) The transplantation
of uclinux Because uclinux is actually an improvement of linux for embedded systems, its structure is more complicated, and the transplantation of uclinux is also much more complicated than uc/os. Generally speaking, in order to transplant uclinux, the target processor needs to have sufficient capacity (a few hundred kilobytes or more) external rom and ram in addition to the above-mentioned conditions for uc/os.
The transplant of uclinux can be roughly divided into three levels:
· The transplant of the structure level, if the structure of the processor to be transplanted is different from any supported processor structure, you need to modify the file of the relevant processor structure in the linux/arch directory. While much of the uclinux kernel code is independent of the processor and its architecture, its lowest-level code is also system-specific. This is mainly manifested in that their interrupt handling context, memory map maintenance, task context and initialization process are unique. These routines are located in the linux/arch/ directory. Due to the wide variety of architectures supported by linux, for a new type of system, its low-level routines can be written by imitating the routines of similar systems.
·平台层次的移植,如果待移植处理器是某种uclinux已支持体系的分支处理器,则需要在相关体系结构目录下建立相应目录并编写相应代码。如mc68ez328就是基于无mmu的m68k内核的。此时的移植需要创建linux/arch/m68knommu/platform/ mc68ez328目录并在其下编写跟踪程序(实现用户程序到内核函数的接口等功能)、中断控制调度程序和向量初始化程序等。
·板级移植,如果你所用处理器已被uclinux支持的话,就只需要板级移植了。板级移植需要在linux/arch/?platform/中建立一个相应板的目录,再在其中建立相应的启动代码crt0_rom.s或crt0_ram.s和链接描述文档rom.ld或ram.ld就可以了。板级移植还包括驱动程序的编写和环境变量设置等内容。

通过对uc/os和uclinux的比较,可以看出这两种操作系统在应用方面各有优劣。uc/os占用空间少,执行效率高,实时性能优良,且针对新处理器的移植相对简单。uclinux则占用空间相对较大,实时性能一般,针对新处理器的移植相对复杂。但是,uclinux具有对多种文件系统的支持能力、内嵌了tcp/ip协议,可以借鉴linux丰富的资源,对一些复杂的应用,uclinux具有相当优势。例如cisco公司的 2500/3000/4000 路由器就是基于uclinux操作系统开发的。总之,操作系统的选择是由嵌入式系统的需求决定的。简单的说就是,小型控制系统可充分利用uc/os小巧且实时性强的优势,如果开发pda和互联网连接终端等较为复杂的系统则uclinux是不错的。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324662104&siteId=291194637