User`s guide

Model Execution
6-11
Running models at interrupt level in real-time multitasking environment is
very similar to the previous singletasking environment, except that overlapped
interrupts are employed for concurrent execution of the tasks.
The execution of a model in a singletasking or multitasking environment when
using real-time operating system tasking primitives is very similar to the
interrupt-level examples discussed above. The pseudocode below is for a
singletasking model using real-time tasking primitives.
tSingleRate()
{
MainLoop:
If clockSem already "given", then error out due to overflow.
Wait on clockSem
ModelOutputs -- Major time step.
LogTXY -- Log time, states and root outports
ModelUpdate -- Major time step
Integrate -- Integration in minor time step for
-- models with continuous states.
ModelDeriviatives
Do 0 or more:
ModelOutputs
ModelDerivatives
EndDo (Number of iterations depends upon the solver.)
Integrate derivatives to update continuous states.
EndIntegrate
EndMainLoop
}
main()
{
Initialization
Start/spawn task "tSingleRate".
Start clock that does a "semGive" on a clockSem semaphore.
Wait on "model-running" semaphore.
Shutdown
}
In this singletasking environment, the model is executed using real-time
operating system tasking primitives. In this environment, we create a single
task (tSingleRate) to run the model code. This task is invoked when a clock tick