Ada Code Generation : Tasks View of the Code : Using Simulated Time Model

Using Simulated Time Model

The generated code uses the real-time model, by default. In this model, timeouts and scheduled actions are treated very similarly to other inputs. The system clock keeps time and generates interrupts which are processed along with the other inputs.

When using this time model, it is possible for the code to miss a timeout or scheduled action due to heavy loading of the processor or an extremely small request for a timeout. In such a situation, the generated code may actually behave slightly different than a simulation of the same model.

Rational Statemate also provides a simulated-time model. The purpose of the simulated-time model is to force the generated code to behave in the same manner as the simulated model. It does this at the cost of the real-time nature of the generated code.

In order to meet all timeouts regardless of duration and CPU loading, the code would be required to run at an arbitrarily fast speed. Since this is not possible, code which is compiled using the simulated-time model, does not adhere to the system clock. Rather, it keeps its own artificial time, much the same as a simulator. An internal counter is kept. The code executes model steps until it reaches an idle status. It then advances the internal clock to the necessary value to execute the next timeout or scheduled action.

-- The main loop, loops forever
procedure main is
. . .
begin
INIT_FUNCTIONS_. . .
. . .
USER_ACTIVITIES.USER_INIT;
. . .
loop
-- Execute a step --
-- Advance internal time keeper to next
relevant step --
-- Apply timeouts and scheduled actions. -
end loop;
exception
. . .
end MAIN;