QP understanding of the RTC

1. Concept

RTC (Run To Completion) is run to completion until the mean. In the state machine from a source state to a target state conversion action to run to completion.

Literally, this process can not be interrupted like, but actually is not, the process can be interrupted by a hardware interrupt routine .

In this state machine , if the execution of an event handler, other event of this state machine arrives, we can only wait in the queue, do not interrupt this process being processed, that is, to run to completion (RTC). This incident has been dealt with in order for other events in the queue for processing. Therefore, active objects (Active Object, AO) always there is a queue which holds the transmission for this event to the state machine.

2. several cases

  • The arrival of more advanced tasks events

Asynchronous event
if the event a task L treatment, the arrival of a hardware interrupt, the interrupt task L event a process (save breakpoints), a hardware interrupt may produce a more advanced task H event b ( asynchronous events ), then before returning execution scheduler, event handling advanced tasks H b, after returning from the top to save the break point, continue unfinished tasks L event a. The event is not a true RTC, event b is interrupted.

Synchronization event
if the task L handle events a, post an event c ( synchronous event ) event c is more advanced tasks H, the post () also calls the scheduler to handle the task H events c, then continue L event a mission in post codes () after. The event is not a true RTC, event c is interrupted.

  • The arrival of an event at the same level task

If the task L process event a time, a hardware interrupt is generated in the event d ( asynchronous events ), or processing event a in post event d ( synchronous event ), the event d belongs task L, the save event d to the corresponding L task queue, the first finished processing the event a, d after the loop process of QK event. Event is a the RTC.

  • The arrival of more low-level tasks events

If an event d (L, the task processing event a, the hardware interrupt asynchronous event ), an event, or a post processing event d (in synchronization event ), the event is part of d L LL lower than the task of the task, the d save event to the task queue corresponding LL, processed first event a, d after the loop process of QK event. Event is a the 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.

Guess you like

Origin www.cnblogs.com/water-sea/p/12059502.html