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. 推卡:“积分侠”的福利 广发DIY信用卡

    广发diy信用卡最大的优势在持卡人在三大类商户刷卡消费可享受3倍积分优惠,很多卡友不知道这些商户到底有哪些,以及商户mcc码是什么,下面和小编一起来看看. 可享受3倍积分的商户类型 持卡人可在以下三大 ...

  2. leetcode Ch2-Dynamic Programming [2014]

    1. Triangle class Solution { public: int minimumTotal(vector<vector<int> > &triangle ...

  3. [问题记录]libpomelo工程调整编译链接错误

    1. 描述: 如下图所示,出现链接错误.那么链接问题一般也就两块设置: (1)包含路径Additional Library Directories (2)lib库的包含Additional Depen ...

  4. photoshopcs6破解补丁用来干嘛的

    photoshopcs6破解补丁为 Adobe CS6 系列软件通用破解补丁,亲测可用,终于能用了不再出现那个烦人的购买页面了,cs6破解补丁解压后得到32和64两个文件夹,根据自己的系统类型选择,6 ...

  5. with优化妙用

    --语法: /*with   alias_name1 as    (subquery1),  alias_name2 as    (subQuery2),  ……  alias_nameN as   ...

  6. Kafka与MQ的区别

    作为消息队列来说,企业中选择mq的还是多数,因为像Rabbit,Rocket等mq中间件都属于很成熟的产品,性能一般但可靠性较强, 而kafka原本设计的初衷是日志统计分析,现在基于大数据的背景下也可 ...

  7. delegate 和 event

    delegate 和 event 观察者模式 这里面综合了几本书的资料. 需求 有这么个项目: 需求是这样的: 一个气象站, 有三个传感器(温度, 湿度, 气压), 有一个WeatherData对象, ...

  8. ubuntu环境安装谷歌驱动命令

    1.sudo apt-get install chromium-chromedriver. 2.直接下载:http://chromedriver.storage.googleapis.com/inde ...

  9. js 获取网页宽/高度

    网页可见区域宽度: document.body.clientWidth 网页可见区域高度: document.body.clientHeight 网页可见区域宽度: document.body.off ...

  10. Android平台上PMEM的使用及Platform设备注册(一)

    Android中PMEM驱动程序是物理内存的驱动程序,可用于分配物理内存.PMEM在camera和video系统中频繁使用.下面,简单记录一下PMEM的使用方法.另外,由于PMEM设备做为Platfo ...