We will use event-driven simulation in several exercises. In this one your assignment is to get a handle on the basics.
Simulation is perhaps the most common method to evaluate computing systems. In particular, event driven simulation is used to trace activities in the system and how they affect each other.
Event-driven simulation is suitable for computer systems because it is discrete: it is based on the assumption that the system does not change in a continuous manner, but rather in discrete events. For example, events may be
Event-driven simulation is based on a queue of pending events. The queue is sorted in timestamp order. The simulation proceeds as follows:
Your assignment is to design and implement the core of an event-driven simulator, i.e. the event queue and mechanism that drives the simulation.
The main design decision you need to make involves the event queue. You need to be able to insert events for arbitrary future times, and retrieve the event with the smallest time. What is a good data structure?
To verify that your engine works, build a small simulation that uses it. For example, define two simple types of events. Event A does nothing except to schedule another event of the same type 2 time units later. Event B likewise does nothing, but schedules another event of the same type 5 time units later. Initially schedule an event A at time 1 and an event B at time 2. Then start the simulation, and keep track of how many events occur at each time instant. Terminate the simulation when simulation time hits 20. Did you get the right results?
You don't need to submit this exercise – it is just a prelude to future exercises. But doing it will help you understand what we'll be doing better. Moreover, what you write here will serve you in several additional exercise and save time later.
Also, when you work on this think about the following points: