next up previous contents
Next: Primitives and event Up: Program structure Previous: Program structure

The event scheduling strategy

When a simulation is set up it runs after invoking the simulation::run method in the session::main function. The simulation then runs until the simulation::quit method is invoked, until there are no events left or for a specified number of time units or terminated events.

At the time an event is due to be activated, it is extracted from the scheduler and the main simulation routine executes the code from the function operator of that event. The scheduling strategy employed by sim is depicted in the following figure.


Notice that the algorithm extracts all events with the same activation time. The main simulation routine activates the events in priority order with the highest scheduling priority first. Before executing the events, the simulation clock is updated to the activation time of the current events. Furthermore, the FIFO conditional list is traversed in priority order with highest scheduling priority first. Events, that can run now, are executed. Events that are not used anymore should be terminated to prevent the system from overflow.

After the running of the simulation some statistics of the starting and end time, of the number of created, activated and terminated events and of the actual time taken are given.

A Eliens
Tue Oct 31 09:27:21 MET 1995