Real-Time Systems: Notes

Example Discrete Event Simulation in C++

 

The example is comprised of the following modules:

prog4 (main program)

prog4_class.cc is the only file; it depends on all the other modules; it calls the initialization functions of each of the other modules and then calls the simulator.

simulator (a generic discrete event simulator)

simulator_class.h is the interface;
simulator_class.cc is the implementation;
it depends directly on module debug.

events ("guts" of the particular simulation)

events_class.h is the interface;
events_class.cc is the implementation;
it depends directly on modules simulator, random, and debug; it uses the simulator interface to register callback handlers for events, and to schedule events, and the random interface to get timings.

random (probability model for the simulation)

random_class.h is the interface;
events_class.cc is the implementation;
it also includes some miscellaneous other code, for debugging support and reading command line arguments.

Please don't be limited by this example or feel you must imitate it closely. When I wrote this code I had not thought through the class design very well. I think I probably could do better if I rewrote it.

© 2003 T. P. Baker. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means without written permission.
$Id