Ada Code Generation : Main Task—Partition and Flow Control for Ada

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 the user_activities.a file and the user_init procedure. Prior to executing the model, you may initialize values in the user_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:

begin
PR_INITIALIZE;
loop
PR_MAKE_STEP;
end loop;
exception
when NUMERIC_ERROR | CONSTRAINT_ERROR =>
REPORT_error(“NUMERIC_ERROR or CONSTRAINT_ERROR
exception raised”);
FINISHING;
when others =>
REPORT_error (“Fatal error: exception raised”);
FINISHING;
end MAIN;
 
 

The following diagram shows the calling sequence within the main task: