User`s guide

6 Program Architecture
6-6
During the ModelOutputs and ModelUpdate phases of model execution, only
blocks that have hit the current point in time execute. They determine if they
have hit by using a macro (
ssIsSampleHit,orssIsSpecialSampleHit)that
checks for a sample hit.
The pseudocode below shows the execution of a model for a multitasking
simulation (nonreal-time).
main()
{
Initialization
While (time < final time)
ModelOutputs(tid=0) -- Major time step.
LogTXY -- Log time, states, and root outports.
ModelUpdate(tid=1) -- Major time step.
For i=1:NumTids
ModelOutputs(tid=i) -- Major time step.
ModelUpdate(tid=i) -- Major time step.
EndFor
Integrate -- Integration in minor time step for models
-- with continuous states.
ModelDerivatives
Do 0 or more:
ModelOutputs(tid=0)
ModelDerivatives
EndDo (Number of iterations depends upon the solver.)
Integrate derivatives to update continuous states.
EndIntegrate
EndWhile
Shutdown
}
The multitasking operation is more complex when compared with the
singletasking execution because the output and update functions are
subdivided by the task identifier that is passed into these functions. This
allows for multiple invocations of these functions with different task identifiers
using overlapped interrupts, or for multiple tasks when using a real-time
operating system. In simulation, multiple tasks are emulated by executing the
code in the order that would occur if there were no preemption in a real-time
system.