Mesquite Software

Home
Products and FAQ
Customers
To Order
Contact Us
Site Map
Documentation
News & Events

Purchase & Download
Or, log in here to
access your account.
 
  Documentation

20. Tracing Simulation Execution

A simulation program, like any other complex software, can be difficult to debug and verify correct. To aid in this, CSIM can produce a log of trace messages during the execution of a simulation. A one-line trace message is produced each time an interesting change in the state of the simulation occurs.

An enormous number of trace messages can be generated by even a short simulation run. For this reason you should try to be selective when enabling different tracing options.

20.1 Tracing All State Changes

The generation of trace messages for all state changes is enabled using the trace_on function. The tracing is disabled using the trace_off function.

Prototype: void trace_on (void)
Example: trace_on ();

Prototype: void trace_off (void)
Example: trace_off ();

Trace messages can be turned on and off as desired during a simulation. Logic can even be added to a simulation to turn on trace messages when a specific condition is detected.

Trace messages can also be enabled by specifying the switch "-T" in the command line that executes the simulation. This feature allows trace messages to be enabled without modifying or recompiling the program. See the documentation for your operating system or programming environment for details on specifying command line switches.

20.2 Tracing a Specific Process

Trace messages that pertain to one specific process or one type of process can be produced using the trace_process function. A specific process is identified by a character string consisting of the name that was specified in the call to function create, followed by a period and the sequence number of the process. If the period and sequence number are omitted, trace messages for all processes created with that name will be generated.

Prototype: void trace_process (char* name)
Example: trace_process ("customer.100");
Example: trace_process ("customer");

Note that in the first example above there is no guarantee that the 100th process that is created will be an instance of customer. If it is not, no trace messages will be produced. The tracing of a specific process can be disabled by calling function trace_off. Successive calls to trace_process will change which process is being traced. There is currently no way to specify a list of processes to trace.

20.3 Tracing a Specific Object

Trace messages that pertain to one specific object (i.e., a facility, storage, event, or mailbox) can be produced using the trace_object function. The object is identified by the character string that was specified when the object was initialized.

Prototype: void trace_object (char* name)
Example: trace_object ("memory");

Note that the type of the object is not specified. If there is more than one object with the specified name, trace messages for all such objects will be produced. The tracing of a specific object can be disabled by calling function trace_off. Successive calls to trace_object will change which object is being traced. There is currently no way to specify a list of objects to trace.

20.4 Format of Trace Messages

Each trace message contains the current simulation time, the name and sequence number of the process that caused the state change, and a description of the state change. Sample trace messages are shown below.

0.716 customer 4 1 use facility cpu for 0.070
0.716 customer 4 1 reserve facility cpu
0.716 customer 4 1 hold for 0.070
0.716 customer 4 1 sched proc: t = 0.070, id = 4
0.787 customer 4 1 release facility cpu

20.5 Program Generated Trace Messages

Any CSIM program can add its own trace messages to the sequence by calling the trace_msg function.

Prototype: void trace_msg (char* string)
Example: trace_msg ("entering procedure for");

Trace messages containing any mixture of text and numeric values can be constructed using the C sprintf function. CSIM will prefix the provided string with the current simulation time and the name and sequence number of the process that produced the message.

20.6 What Is and Is Not Traced

Ideally, every occurrence that changes the state of a CSIM object will generate a trace message. In particular, any occurrence that causes time to pass should be traced.

Occurrences that do not produce trace messages include 1) the generation of random numbers, 2) the updating of performance statistics, and 3) the production of reports. Obviously, non-CSIM operations such as updates of local variables can not produce trace messages.

20.7 Redirecting Trace Output

By default, trace messages are written to file stdout. Trace messages can be redirected to a different file using the function set_trace_file.

Prototype: void set_trace_file (FILE * file_pointer)
Example: *fp = fopen ("trace", "w"); set_trace_file (fp);

Next Section

 
Home | Products/FAQ | Customers | To Order | Contact Us | Site Map | Documentation
© copyright 2005, Mesquite Software, all rights reserved.