Main Task—Partition and Flow Control for Ada
In this section we describe how the different generated modules are put together into a single thread, and what is the control flow of the main task. The whole execution starts with an initialization phase, where all components are initialized: the timer, the threads scheduler (if needed) and basic activity tasks are created. In addition the user_init procedure is called.
The user_init procedure resides in a file called
user_activities.a
. When you generate code, the Code Generator automatically creates theuser_activities.a
file and theuser_init
procedure. Prior to executing the model, you may initialize values in theuser_init
procedure.After the initialization phase, the main-task starts processing in a cyclic manner, where every cycle corresponds to a single “go-step.’ In every cycle, all the concurrent state machines are traversed, process their inputs and generate outputs, issue timing requests and take the necessary state transitions.
This is how the Main procedure program looks:
The following diagram shows the calling sequence within the main task: