Analysis of uC/OS-II kernel architecture (1)-embedded RTOS

Source: Internet
Author: User
1. Basic models of Embedded Systems

2. RTOS Design Principles

Various algorithms and policies are used to ensure the predictability of system behavior. That is to say, in any situation and at any time when the system is running, the Resource Configuration Policy of the OS can compete for resources (including CPU, memory, and network bandwidth) allows you to allocate resources to multiple real-time tasks, so that the real-time requirements of each real-time task can be met.

3. gpos and RTOS
  • Gpos: Pay attention to the average response time of each execution, rather than the response time of a specific execution.
  • RTOS: in addition to meeting application functional requirements, it must also meet real-time requirements and always ensure the predictability of system behavior (predictability ).

Unlike gpos, RTOS focuses not on the average performance of the system, but on the real-time performance of each real-time task in the worst case. That is to say, RTOS focuses on individual performance and, more accurately, the worst-case performance of an individual.

The main differences between RTOS and gpos are as follows:

A) The task scheduling policies are different;

B) memory management methods are different;

C) interrupt handling methods are different;

D) Different system management methods;

4. Embedded Development Mode
  • Single-Chip Microcomputer System front and back-end program: No OS is used, the application is designed as an endless loop, the system takes turns to handle various events, asynchronous events with high time response requirements are handled by interruption.
  • The Software Design Method Based on Task (process): the OS is used to manage hardware resources. The task can only be applied when resources are required. As for the when/which, it is entirely determined by the OS.
5. (not) Reentrant

(1) reentrant function: A function code that can be interrupted during running and can be restored to the original state after being interrupted and returned, and can be accurately executed.

A reentrant function can be called by more than one task without worrying about data corruption. You can reload the function or only use local variables, that is, the variables are stored in the CPU register or stack; or use global variables to protect global variables.

(2) Non-reentrant function: the function cannot be interrupted during running.

6. mutex Conditions

The easiest way to implement inter-task communication is to use shared data, but ensure that tasks are arranged when processing shared data. To make shared resources meet the mutex conditions, the most common methods are:

(1) Guanzhong disconnection

When a real-time kernel is used, the shutdown duration generally does not exceed the shutdown duration of the kernel, so that the system interruption delay is not affected.

(2) Use the test reset command

The Test & set operation may be an instruction on the microprocessor that will not be interrupted. Otherwise, the TAS operation should be disabled in the program and then interrupted.

(3) task switching is prohibited.

In this case, task switching is forbidden, but interruption is still allowed. If the interruption occurs, ISR will be executed immediately in this critical section.

(4) use semaphores;

7. Critical status

The critical State indicates that the current program is not interrupted. Generally, you must enter the critical state before calling the function or when modifying the global variable data. The main operation to enter the critical state is to disable all blocked interruptions, and the main operation to exit the critical state is to restore to the interrupted management status before the last entry into the critical state.

In uC/OS-II, the macro OS _enter_critical () describes the operation completed to enter the critical state, and the macro OS _exit_critical () describes the operation to exit the critical state. UC/OS-II provides three ways to enter and exit the critical state, according to the CPU type by macro OS _critical_mothod specify the specific critical state solution.

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.