新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > 单片机操作系统RTX51原理分析与移植

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

作者:时间:2013-01-07来源:网络收藏

一.课题要求:

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

二.原理

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

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 with which the following operations can be executed:

l Wait for a signal

l Send signal

l Clear signal

The task number (see section section "Task Declaration") of the receiver task is used for identifying the signals for the individual operations.

2. Message(via MailBoxes(FIFO))

n By means of the mailbox concept, messages can be exchanged free of conflicts between the individual tasks.

n RTX-51 provides a fixed number of eight mailboxes. Messages can be exchanged in words (2 bytes) via these mailboxes. In this case, a message can represent the actual data to be transferred or the identification of a data buffer(defined by the user). In comparison to the signals, mailboxes are not assigned a fixed task, but can be freely used by all tasks and interrupt functions. These are identified with a mailbox number.

Mailboxes allow the following operations:

l Send a message

l Read a message

linux操作系统文章专题:linux操作系统详解(linux不再难懂)

上一页 1 2 3 下一页

评论


相关推荐

技术专区

关闭