User`s guide

Single- Versus Multitasking Environments
7-5
Executing Multitasking Models
In cases where the continuous part of a model executes at a rate that is
different from the discrete part, or a model has blocks with different sample
rates,thecodeassignseachblockatask identifier (tid) to associate it with the
task that executes at its sample rate.
Certain restrictions apply to the sample rates that you can use:
The sample rate of any block must be an integer multiple of the base (i.e., the
fastest) sample rate. The base sample rate is determined by the fixed step
size specified on the Solver page of the Simulation parameters dialog box
(if a model has continuous blocks) or by the fastest sample time specified in
the model (if the model is purely discrete). Continuous blocks always execute
via an integration algorithm that runs at the base sample rate.
The continuous and discrete parts of the model can execute at different rates
only if the discrete part is executed at the same or a slower rate than the
continuous part (and is an integer multiple of the base sample rate).
Multitasking and Pseudomultitasking
In a multitasking environment, the blocks with the fastest sample rates are
executed by the task with the highest priority, the next slowest blocks are
executed by a task with the next lower priority, and so on. Time available in
between the processing of high priority tasks is used for processing lower
priority tasks. This results in efficient program execution.
See “Multitasking System Execution” on page 7-6 for a graphical
representation of task timing.
In multitasking environments (i.e., a real-time operating system), you can
define separate tasks and assign them priorities. In a bare-board target (i.e.,
no real-time operating system present), you cannot create separate tasks.
However, the Real-Time Workshop application modules implement what is
effectively a multitasking execution scheme using overlapped interrupts,
accompanied by manual context switching.
This means an interrupt can occur while another interrupt is currently in
progress. When this happens, the current interrupt is preempted, the
floating-point unit (FPU) context is saved, and the higher priority interrupt
executes its higher priority (i.e., faster sample rate) code. Once complete,
control is returned to the preempted ISR.