next up previous contents
Next: The TimeWarp class Up: Organization Previous: Organization

The Application Interface

The WARPED kernel presents an interface to the application that is based on Jefferson's original paper on TimeWarp. Objects are modeled as entities which send and receive events to and from each other, and act on these events by applying them to their internal state. This being the case, basic functions that the kernel provides to the application are methods for sending and receiving events [*] between simulation objects, and the ability to specify different types of objects with unique definitions of state.

One departure from Jefferson's presentation of TimeWarp is that simulation objects are placed into groups called ``logical processes.'' (LPs) Simulation objects on the same logical process communicate with each other without intervention from the message system, which is much faster than communication through it. Hence, objects which communicate frequently should be placed on the same logical process. Another feature of the logical process is that it is responsible for scheduling the simulation objects. Note that the simulation objects within an LP operate as TimeWarp processes; even though they are grouped together, they aren't coerced into synchronization.

Control is passed between the application and the kernel through the cooperative use of function calls. This means that when a function is called in application code, the application is not allowed block for any reason. Since the application has control of the single thread of control through its LP, it could end up waiting forever.

In order for the kernel to correctly interact with the application code, the user must provide several functions to the kernel. These functions define such things as how to initialize each simulation object, and what each simulation object does during a simulation cycle. In addition, if the user would like to use a non-integer definition of time, facilities are in place to provide a user-defined time class to the kernel.

The application interface to the system is achieved through several features of the C++ language. The simulation kernel is defined as several template classes, allowing the user to define system parameters without rewriting system code. Application specific code is derived from the WARPED kernel. This allows application code to transparently access kernel functions.

In the following sections, a detailed description of the application interface is presented. As an example, a ``ping pong'' application will be developed. Each object in the system merely forwards any event that it receives to the next object in a circular fashion. If there are only two objects in the simulation, the event will be passed back and forth as though they are playing ping pong. We will model our simulation objects so that they will hit the ``ball'' a maximum number of times, at which time the simulation will be complete. The actual source code of this example application is available in the examples directory within the WARPED distribution. Refer to the README file in the examples directory on detailed instructions on running the example[*].


next up previous contents
Next: The TimeWarp class Up: Organization Previous: Organization
Philip A. Wilsey
1/26/1998