Real-Time Workshop    

Singletasking Execution

In this section, we will consider the execution of the model when the solver mode is SingleTasking.

Note that in a singletasking system, if the Block reduction option is on, fast-to-slow Rate Transition blocks are optimized out of the model. We show the default case (Block reduction on); therefore block B does not appear in the timing diagrams in this section.

Table 8-1 shows, for each block in the model, the execution order, sample time, and whether the block has an output or update computation. Block A does not have discrete states, and accordingly does not have an update computation.

Table 8-1: Execution Order and Sample Times (Singletasking)
Blocks
(in Execution Order)

Sample Time
(in seconds)

Output
Update
F
0.1
Y
Y
E
0.1
Y
Y
D
1
Y
Y
A
0.1
Y
N
C
1
Y
Y

Real-Time Singletasking Execution

Figure 8-11 shows the scheduling of computations when the generated code is deployed in a real-time system. The generated program is shown running in real time, under control of interrupts from a 10 Hz timer.

Figure 8-11: Singletasking Execution of Model in a Real-Time System

At time 0.0, 1.0, and every second thereafter, both the slow and fast blocks execute their output computations; this is followed by update computations for blocks that have states. Within a given time interval, output and update computations are sequenced in block execution order.

The fast blocks execute on every tick, at intervals of 0.1 sec. Output computations are followed by update computations.

Note that the system spends some portion of each time interval (labelled "wait") idling. During the intervals when only the fast blocks execute, a larger portion of the interval is spent idling. This illustrates an inherent inefficiency of SingleTasking mode.

Simulated Singletasking Execution

Figure 8-12 shows the execution of the model in Simulink via the simulation loop.

Figure 8-12: Singletasking Execution of Model in Simulink

Since time is simulated, the placement of ticks represents the iterations of the simulation loop. Blocks execute in exactly the same order as in Figure 8-11, but without the constraint of a real-time clock. Therefore there is no idle time between simulated sample periods.


  Singletasking and Multitasking Execution of a Model: an Example Multitasking Execution