Design Category: Other Articles Source: www.lw63.com Computer Papers 32 Update Time: 2008-10-214:19: 52 | Font: Xiao Da.
2. 1.3 embedded real-time operating system
Real Time Operating System is a real-time system based on the operating characteristics of the operating system and can support real-time control. Its main task is to schedule all available resources to complete real-time control tasks and improve reliability. Secondly, it focuses on improving the efficiency of the system and meeting time constraints and requirements. RTOS is the foundation and development platform of embedded application software, which should have the following functions:
1). Task management (multitask and priority-based task scheduling);
2) Synchronization and communication between tasks (semaphore, mailbox and message queue);
3). Memory optimization management (including ROM management)
4). Real-time clock service
5). Interrupt management service
The task in real-time operating system is equivalent to the concept of process in real-time operating system. There are four states of tasks in the system: executed, ready, suspended and dormant.
Run: gain CPU control;
Ready: enter the task waiting queue and transfer to the running state through scheduling;
Suspend: the task is blocked, moved out of the task waiting queue, and wakes up the real-time events of the waiting system, thus turning into a ready or running state;
Hibernate: A task that has been deleted due to completion or error.
At any time, only one task is running.
RTOS is an important branch of operating system research. It has the same side as the general commercial multitasking operating systems (such as Unix and Windows), but it also has a different side. For commercial multitasking OS, its purpose is to facilitate users to manage computer resources and pursue the maximum utilization of system resources; RTOS pursues real-time scheduling, certainty of time response time and high reliability. The evaluation of a real-time operating system can generally be measured from several aspects, such as task scheduling, memory management, task communication, memory overhead, task switching time, and maximum interrupt prohibition time. Therefore, the main problems to be solved by RTOS are as follows:
(1) Task scheduling mechanism:
The real-time performance and multi-task ability of RTOS largely depend on its task scheduling mechanism. In the aspect of scheduling strategy, it is divided into priority scheduling strategy and time slice rotation scheduling strategy; In terms of scheduling methods, it can be divided into preemptive, nonpreemptive and preemptive scheduling methods; From the perspective of time slice, it can be divided into fixed and variable time slice rotation. From the perspective of preemptive scheduling mode based on priority, there are many methods to calculate priority.
In most commercial real-time systems, in order to enable the operating system to quickly gain control of the system in case of emergency so as to respond in time, most of them provide the function of "preemptive task scheduling", that is, the operating system has the right to terminate the execution of the application (application task) and hand over the execution right to the task with the highest priority.
⑵ Memory management
Like time-sharing operating system, real-time operating system uses memory management unit (MMU) for memory management. The memory management mode of real-time operating system can be divided into real mode and protected mode (mainly for Intel x86). At present, mainstream real-time operating systems can generally provide two modes for users to choose independently according to their applications.
(3) Minimum memory overhead
In the design process of RTOS, the minimum memory overhead is an important indicator, because in some industrial computers in the industrial control field (such as the lower computer in the upper and lower computer control system), for the sake of reducing the cost, the memory configuration is generally not very large, and not only the real-time operating system but also the user program should be loaded in this limited space. Therefore, in the design of RTOS, its occupied memory size is a very important indicator, which is also one of the obvious differences between RTOS design and other operating system design.
(4) Maximum interrupt prohibition time and interrupt delay time
When RTOS runs in kernel mode or performs some system calls, the execution will not be interrupted by the arrival of external interrupts. Only when RTOS returns to user mode can it respond to external interrupt requests. The maximum time required for this process is the maximum interrupt prohibition time.
Interrupt waiting time refers to the time required for the system to confirm the start of the interrupt until the first instruction of the interrupt service program is executed. The interrupt delay time of real-time operating system is determined by the following three factors: the delay time of processor hardware circuit is usually negligible; The time required for the real-time operating system to handle interrupts and transfer control to related handlers; Interrupt prohibition time of real-time operating system.
5] Task switching time (context switching time)
When a task quits running for some reason, RTOS saves its running site information, inserts it into the corresponding queue, and re-selects a new task to run according to a certain scheduling algorithm. The time required for this process is called task switching time. More precisely, the task switching time is the time required for the real-time operating system to retrieve control from the execution of one task and then hand it over to another task. Including the time required to save the on-site information of the currently executing task, RTOS determines the scheduling time required for the next scheduled task, and RTOS transfers another task to the time required for system execution.
Among them, the maximum interrupt prohibition time and task switching time are the two most important technical indicators to evaluate the real-time performance of RTOS.