#include <ssim.h>
Static Public Methods | |
ProcessId | create_process (Process *, char mode=0) |
creates a new process | |
int | stop_process (ProcessId) |
stops the execution of a given process | |
void | stop_process () |
stops the execution of the current process | |
void | clear () |
clears out internal data structures | |
int | signal_event (const Event *, ProcessId) |
signal an event to the given process | |
int | signal_event (const Event *, ProcessId, Time) |
signal an event to the given process at the given time | |
void | set_timeout (Time) |
sets a timeout for the current process | |
void | advance_delay (Time) |
advance the execution time of the current process. | |
ProcessId | this_process () |
returns the current process | |
Time | clock () |
returns the current virtual time for the current process | |
void | run_simulation () |
starts execution of the simulation | |
void | stop_simulation () |
stops execution of the simulation | |
Static Public Attributes | |
const char | P_SEQUENTIAL = 0x02 |
P_SEQUENTIAL flag | |
const char | P_QUEUING = 0x04 |
P_QUEUEING flag |
This class implements a generic discrete-event sequential simulator. Sim maintains and executes a time-ordered schedule of actions (or discrete events).
|
advance the execution time of the current process. This method can be used to specify the duration of certain actions, or certain steps within the same action. For example:
class SomeProcess : public Process { //... virtual void process_event(const Event * e) { // // suppose this response is called at (virtual) time X // ...do something here... // the above actions have a default duration of 0, // therefore the following event is scheduled at time X + 5 // signal_event(e, p, 5); advance_delay(10); // ...do something else here... // advance_delay(10) specifies a duration of 10, therefore // the following timeout is scheduled at time X + 15; // set_timeout(5); } };
|
|
clears out internal data structures Resets the simulator making it available for a completely new simulation. All scheduled actions are deleted together with the associated events. All process identifiers returned by previoius invocations of create_process are invalidated by this operation. Notice however that it is the responsibility of the simulation programmer to delete process objects used in the simulation. |
|
returns the current virtual time for the current process Example: void LoopProcess::process_timeout() { cout << "Here I am at time:" << Sim::clock() << endl; set_timeout(20) cout << "I just scheduled myself again for time: " << Sim::clock() + 20 << endl; }
|
|
creates a new process
creates a new process with the given Process object. |
|
sets a timeout for the current process Schedules the execution of process_timeout() on the current process after the given amount of (virtual) time. |
|
signal an event to the given process at the given time
|
|
signal an event to the given process Signal an event to the given process. The response is scheduled for the current time.
|
|
returns the current process Example: void SimpleProcess::process_event(const Event *e) { cout << "my process id is: " << Sim::this_pocess() << endl; } |