1.概念

RTC(Run To Completion)是运行到完成为止的意思。在状态机中,从源状态到目标状态的转换动作要运行到完成。

从字面上来看,这个过程像是不可中断的,但实际并不是,这个过程可以被硬件中断程序打断

在本状态机中,一个事件处理要是执行了,本状态机的其它事件到来时,就只能在队列中等待,不可中断这个正在处理的过程,也就是要运行到完成(RTC)。这个事件处理完后,才能对队列中的其它事件进行处理。所以在活动对象(Active Object,AO)中总是有一个队列,这个队列用来保存发送到本状态机的事件的。

2. 几种情况

  • 更高级任务的事件到来

异步事件
如果在任务L处理事件a时,硬件中断到来了,中断了任务L的事件a处理过程(保存断点),硬件中断中可能产生一个更高级任务H的事件b(异步事件),则在中断返回前执行调度器,处理高级任务H的事件b, 之后,从上边保存的断点返回,继续执行没有完成的任务L的事件a。事件a不是真正的RTC,被事件b中断了。

同步事件
如果在任务L处理事件a时,post了一个事件c(同步事件), 事件c是更高级任务H的,则post()中也调用调度器,先处理任务H的事件c, 之后继续执行任务L的事件a中post()后的代码。事件a不是真正的RTC,被事件c中断了。

  • 同级任务的事件到来

如果在任务L处理事件a时,硬件中断中产生了事件d(异步事件),或处理事件a中post了事件d(同步事件), 事件d是属于任务L的,则保存事件d到对应的任务L的队列中,先处理完事件a,之后由QK的循环处理事件d。事件a是RTC的。

  • 更低级任务的事件到来

如果在任务L处理事件a时,硬件中断中产生了事件d(异步事件),或处理事件a中post了事件d(同步事件), 事件d是属于比任务L更低的任务LL的,则保存事件d到对应的任务LL的队列中,先处理完事件a,之后由QK的循环处理事件d。事件a是RTC的。

请参考Miro Samek以下的说明:
Miro Samek:"All state machine formalisms, including UML statecharts, universally assume that a state machine completes processing of each event before it can start processing the next event. This model of execution is called run to completion, or RTC.

In the RTC model, the system processes events in discrete, indivisible RTC steps. New incoming events cannot interrupt the processing of the current event and must be stored (typically in an event queue) until the state machine becomes idle again. These semantics completely avoid any internal concurrency issues within a single state machine. The RTC model also gets around the conceptual problem of processing actions associated with transitions, where the state machine is not in a well-defined state(is between two states) for the duration of the action. During event processing, the system is unresponsive (unobservable),so the ill-defined state during that time has no practical significance.

Note, however, that RTC does not mean that a state machine has to monopolize the CPU until the RTC step is complete. The preemption restriction only applies to the task context of the state machine that is already busy processing events. In a multitasking environment, other tasks (not related to the task context of the busy state machine) can be running, possibly preempting the currently executing state machine. As long as other state machines do not share variables or other resources with each other, there are no concurrency hazards.

The key advantage of RTC processing is simplicity. Its biggest disadvantage is that the responsiveness of a state machine is determined by its longest RTC step.4 Achieving short RTC steps can often significantly complicate real-time designs.
"

对QP中RTC的理解的更多相关文章

  1. Fouandation(NSString ,NSArray,NSDictionary,NSSet) 中常见的理解错误区

    Fouandation 中常见的理解错误区 1.NSString //快速创建(实例和类方法) 存放的地址是 常量区 NSString * string1 = [NSString alloc]init ...

  2. linux中socket的理解

    对linux中socket的理解 一.socket 一般来说socket有一个别名也叫做套接字. socket起源于Unix,都可以用“打开open –> 读写write/read –> ...

  3. 谈谈我对Java中CallBack的理解

    谈谈我对Java中CallBack的理解 http://www.cnblogs.com/codingmyworld/archive/2011/07/22/2113514.html CallBack是回 ...

  4. JavaScript中的闭包理解

    原创文章,转载请注明:JavaScript中的闭包理解  By Lucio.Yang 1.JavaScript闭包 在小学期开发项目的时候,用node.js开发了服务器,过程中遇到了node.js的第 ...

  5. 网站开发进阶(三十四)编码中的setCharacterEncoding 理解

    编码中的setCharacterEncoding 理解 1.pageEncoding="UTF-8"的作用是设置JSP编译成Servlet时使用的编码. 2.contentType ...

  6. 关于zynq7 中MIO的理解

    关于zynq7 中MIO的理解 Zynq7000有54个MIO,分配在GPIO的Bank0和Bank1,属于PS部分,这些IO与PS直接相连,不需要添加引脚约束,MIO信号对PL部分是不可见的,对MI ...

  7. Java 泛型 <? super T> 中 super 怎么 理解?与 < ? extends T>有何不同?

    Java 泛型 <? super T> 中 super 怎么 理解?与 extends 有何不同? 简介 前两篇文章介绍了泛型的基本用法.类型擦除以及泛型数组.在泛型的使用中,还有个重要的 ...

  8. 沉淀再出发:关于java中的AQS理解

    沉淀再出发:关于java中的AQS理解 一.前言 在java中有很多锁结构都继承自AQS(AbstractQueuedSynchronizer)这个抽象类如果我们仔细了解可以发现AQS的作用是非常大的 ...

  9. 关于NAND flash的MTD分区与uboot中分区的理解

    关于NAND flash的MTD分区与uboot中分区的理解 转自:http://blog.csdn.net/yjp19871013/article/details/6933455?=40085044 ...

随机推荐

  1. Kettle数据抽取解决方案

    一. Kettle介绍 1. Kettle简介 ETL即数据抽取(Extract).转换(Transform).装载(Load)的过程.Kettle的中文翻译为水壶.Kettle以元数据驱动的方式提供 ...

  2. SQL Server ->> 校检函数CHECKSUM、CHECKSUM_AGG、BINARY_CHECKSUM和HASHBYTES

    今天特地查了一下SQL Server下的校检函数有哪些.原本我只是在工作中用过一个CHECKSUM,今天特地学习了一下才发现原来还有其他的校检函数. 这里找到了别人对于SQL SERVER下这几个校检 ...

  3. WCF服务上应用protobuf z

    protobuf是google提供的一个开源序列化框架,类似于XML,JSON这样 的数据表示语言,其最大的特点是基于二进制,因此比传统的XML表示高效短小得多.虽然是二进制数据格式,但并没有因此变得 ...

  4. 学习的矩阵微积分The matrix calculus you need for deep learning

    学习的矩阵微积分The matrix calculus you need for deep learning https://explained.ai/matrix-calculus/index.ht ...

  5. awrsqrpt.sql简介

    ORACLE_HOME/RDBMS/admin/awrsqrpt.sql  这个脚本可以很方便地取出某个sql在某两个快照间隔内,消耗cpu时间,执行次数,逻辑读,物理读,sql的执行计划以及sql的 ...

  6. 最详细的Vue Hello World应用开发步骤

    很多Vue的初学者想尝试这个框架时,都被webpack过于复杂的配置所吓倒,导致最后无法跑出一个期望的hello word效果.今天我就把我第一次使用webpack打包一个Vue Hello Worl ...

  7. [转]How to Leak a Context: Handlers & Inner Classes

    Consider the following code: public class SampleActivity extends Activity { private final Handler mL ...

  8. Using the @synchronized Directive

    https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/ThreadSafe ...

  9. BZOJ3312:[USACO]No Change(状压DP)

    Description Farmer John is at the market to purchase supplies for his farm. He has in his pocket K c ...

  10. 【[USACO15JAN]草鉴定Grass Cownoisseur】

    这大概是我写过的除了树剖以外最长的代码了吧 首先看到有向图和重复经过等敏感词应该能想到先tarjan后缩点了吧 首先有一个naive的想法,既然我们要求只能走一次返回原点,那我们就正着反着建两遍图,分 ...