Tutorials to .com

Tutorials to .com » Mechine » Embed » Real-time operating system, μC / OS-II Improvement and Application of Research

Real-time operating system, μC / OS-II Improvement and Application of Research

Print View , by: iSee ,Total views: 20 ,Word Count: 1681 ,Date: Sun, 23 Aug 2009 Time: 10:01 PM

Most of the traditional embedded system design using a single task order mechanism, the application program is an infinitely large loop, all events are sequential implementation, and time-related events that rely on strong timer interrupt to ensure that the resulting system stability, real-time poor; especially when the system function more complex, and real-time requirements more stringent, this single task exposing the weaknesses of the mechanism. This paper introduces an embedded operating system, μC / OS-II is a multi-task real-time kernel, mainly to provide task management functions. In the real-time system multiple tasks, must decide the priority order of these tasks, dynamic task scheduling algorithm needs to place the priority of the task order. In order to meet the increasingly demanding real-time needs, while avoiding frequent changes in priority ready task in the analysis of μC / OS-II source code, based on its scheduling algorithm to improve it.

1 μC / OS-II Overview

μC / OS-II is a complete, portable, can be cured can be cut in preemptive real-time multi-task kernel; supports 56 user tasks to support semaphores, mailboxes, message queues, etc. commonly used in inter-process communication mechanism; apply a variety of micro-controllers and microprocessors; all of the code used ANSI c language, the program's readable, has good portability, has been ported to a variety of processor architectures, in some real-time requirements rigorous field be widely applied.

1.1 Working Principle

μC / OS-II's core principle is: approximate to let the highest priority ready task is running. First, initialize the MCU, and then to the operating system is initialized, the main task control block TCB initialization, TCB priority list is initialized, TCB list is initialized, the event control block (ECB) to initialize the list and air mission to create and so on. Then, start creating new tasks, and can be newly created task and then create other new tasks. Finally, the ridicule in loud voice with OSStart () function to start multi-task scheduling. After the start of a multi-task scheduling, start the clock start time beats the source, this beats the source to the system clock to provide periodic interrupt signal, to achieve delay and timeout to confirm.

1.2 Task Scheduling

The operating system in the following circumstances Task Scheduling: interrupt (the system occupied by the time slice interrupt OSTimeTick (), user-interrupts), and call the API function (user take the initiative to call). One is the clock interrupt comes, the system to perform tasks currently suspended, to protect the site for interrupt handling, to determine whether the task delay expired; if there is no other tasks into the ready state, then restore the site to continue the implementation of the original. Another scheduling approach is task-level scheduling, that is, call the API functions (by the user take the initiative to call), become soft enough to break through the processor in the task order or to rely on the implementation of the scheduling. When there is no any task into the ready state, the go from operational tasks.

2 Scheduling Algorithm

2.1 Real-Time System Scheduling Policies

The multi-tasking operating system scheduling algorithm design, according to the specific needs of the system to determine the scheduling policy. Real-time scheduling strategy according to different methods can be divided into: static / dynamic, priority-based / non-priority-based, preemptive / non-preemptive, single-processor / multi-processor. Among them, static refers to the task during the whole life remain the same priority, the task's priority is the establishment of the task in the system determined at the time; dynamics refers to the life of the mission period, at any time to determine or change its priority level, to adapt to the system working environment and conditions change.

μC / OS-II system uses a static priority assignment strategy for each task by the user to specify the priority. While the priority of the task can be OSTaskChangePrio () function is changed, but the function function of simple, only the new user-specified priority of the task to replace the current priority. With the real-time embedded technology, real-time embedded systems increasingly demanding and diverse scheduling method has become a trend. This article discusses the dynamic priority scheduling algorithm in the optimal earliest deadline first algorithm and its in μC / OS-II in the implementation.

2.2 Scheduling Algorithm

The earliest deadline first algorithm is a dynamic priority scheduling algorithm in the optimal algorithm. In the earliest deadline first algorithm, the system cut-off date according to the task assigned to each task priority. The earlier deadline tasks the higher its priority level and vice versa. To this end, as described in this article the earliest deadline first algorithm improvements. Need to μC / OS-II system to increase the items listed in Table l.

Real-time operating system, μC / OS-II Improvement and <a href=application of Research" />

In the earliest deadline first algorithm, require the user to specify the deadline for the task. In this improvement, you will OSTaskCreate () and OSTaskCreateExt () parameter INT8U Prio changed INT8U deadline, and the definition of local variables within the function to record the INT8U Prio assigned to the task priority. The algorithm to improve the system also increases OSTaskPrioCreate () function, the function priority allocation method is based on the allocation of the task deadline. The module process as shown in Figure l.

Real-time operating system, μC / OS-II Improvement and Application of Research

In the right place to adjust task priority, the module first in the array right to adjust the priority of the task and record the task priority of the adjustments. In the implementation of this function, the ready task queue priority of the task may change, this park also need to μC / OS-II system, adding prio_adjust () function. The function application μC / OS-II system, the original function of OSTaskChangePrio () to update the ready tasks, the code is as follows:

Real-time operating system, μC / OS-II Improvement and Application of Research

In order to prevent more than one task simultaneously is called OSTaskPrioCreate () function, causing confusion, this code should be of critical resources to address the need to break off the call before the call and then break open.

3 Application and Evaluation

3.1 System architecture

HPMC in the hydraulic measurement control module, the system requires 18ms to complete the seven locations within the sensor and user data in real-time keyboard collection, processing and display; and for the different measurement data collected require system based on the urgency of the task, make a priority of different real-time response.

Structure of the system shown in Figure 2. From outside to inside is divided into three layers: the hardware circuit layer, task layer and the operating system layer.

Real-time operating system, μC / OS-II Improvement and Application of Research

Hardware circuit layers include HPMC modules, the user operation, microcomputer control module. Generally functions as follows: HPMC module of the completion of the real-time sensor data collection; user module of the completion of the user's operation; mcu control module for controlling data reception, processing, sending, send and receive short messages and so on.

Task level parallelism exists lO task, each task by the following three parts: application, task stacks and task control blocks, the main task of priority setting, and task state of dynamic transition.

The operating system layer designed primarily to μC / OS-II port to the microcontroller. The system uses Atmel's microcontroller MCS-5l series is compatible with the same time, the completion of each task a specific program.

3.2 Algorithm evaluation

Choose to use dynamic scheduling or static scheduling is very important, this will have a profound impact on the system. Static scheduling of time-triggered system design is very suitable, and dynamic scheduling of the event-triggered system design well suited. Static scheduling must be carefully designed in advance, and spending a lot of effort to consider selecting a wide variety of parameters; dynamic scheduling does not require the amount of work in advance, but dynamically during the execution of decisions.

In the HPMC module, due to the need for field measurement data collected in real-time processing, so the system put forward a very high real-time requirements. To use μC / OS-II of the static priority scheduling algorithm, when the system task priority change look powerless; same time, through the hydraulic control system of measurement shows that the improved real-time, after the system has been greatly improved .


In this paper, μC / OS-II static scheduling algorithm improved the system to achieve a deadline of priority scheduling algorithm. Through the hydraulic control system of measurement, indicating that such improvements can improve the system of real-time; but the improved algorithm of the system memory, CPU and so on a higher demand, there are some limitations.

Embedded Systems Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.