微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 单片机操作系统RTX51原理分析与移植

单片机操作系统RTX51原理分析与移植

时间:01-07 来源:互联网 点击:

一.课题要求:

仔细分析单片机操作系统RTX51的原理,将其移植到单片机实验平台上,并要求编写一个简短的程序来验证其运行的正确性(比如,编写两个具有显示不一样内容的任务)。

二.RTX51原理

注释:由于英文原文会比较好,所以我没有翻译过来(不过也写了部分的翻译),直接提取出来一些英文,总结在一起。

1. 进程管理( Task Management )

1) 进程类型( Classes of Tasks )

RTX-51 recognizes two classes of tasks:

1. Fast tasks

n Contain especially short responses and interrupt disable times.

n Contain a separate register bank and a separate stack area (register banks 1, 2 and 3).(Figure 1)

n Contain the highest task priority (priority 3) and can therefore interrupt standard tasks.

n All contain the same priority and can therefore not be mutually interrupted.

n Can be interrupted by c51 interrupt functions.

n A maximum of three fast tasks can be active in the system.

2. Standard tasks

n Require somewhat more time for the task switching compared to fast tasks.

n Share a common register bank and a common stack area (register bank 0).

n The current contents of registers and stack are stored in the external (XDATA) memory during a task change.

n Can be interrupted by fast tasks.

n Can interrupt themselves mutually.

n Can be interrupt by c51 interrupt functions.

n A maximum 16 standard tasks can be active in the system.

Figure 3: Task Classes and Memory Allocation

每一个标准进程都包含一个设备上下文在扩展内存(XDATA)中。在标准进程执行进程切换的时候,会把它自己的Register和Stack存储到对应的设备上下文中(在扩展内存中的一个区域)。之后,Register和Statck又从设备上下文中重新载入,继续执行。(交换技术)

相比而言,快速进程则不用这么麻烦,因为它们有各自独立的Register和Stack,所以只要激活对应的Register(修改PSW)和指向Stack的指针(Mov SP,#XX)即可。

2) 进程状态(Task states)

RTX-51 recognizes four task states:

1. READY All tasks which can run are READY. One of these tasks is the RUNNING (ACTIVE)task.

2. RUNNING (ACTIVE) Task which is currently being executed bythe processor. Only one task (maximum) can be in this state at a time.

3. BLOCKED (WAITING) Task waits for an event.

4. SLEEPING All tasks which were not started or which have terminated themselves are in this state.

3) 进程调度(Task switch)

The RTX-51 system section which the processors assigns to the individual tasks is referred to as the scheduler (also dispatcher).

The RTX_51 scheduler works according to the following rules:

1. The task with the highest priority of all tasks in the READY state is executed.

2. If several tasks of the same priority are in the READY state,the task that has been ready the longest will be the next to execute.

3. Task switchings are only executed if the first rule would have been otherwise violated (exception: round-robin scheduling).

Time-slice task change (round-robin scheduling) are executed if the following conditions are satisfied:

1. Round-robin scheduling must be enabled (see configuration).

2. The RUNNING task has the priority of 0 and is currently not executing a floating-point operation (see section "Floating-Point Operations", page 28).

3. At least one task with the priority zero must be in the READY state.

4. The last task change must have occurred after the selected system time interval (see system function "os_set_slice"). The system time interval can be changed dynamically during program execution.

4) 进程通信和同步(Task Communication and Synchronisation)

There three two mechanisms:

1. Signal

Signals represent the simplest and fastest form of task communication. These can always be used when a pure task synchronisation is required without data exchange.

Each active task contains its own signal flag

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top