SSim C++ API documentation (v. 1.3.2)

Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Examples  

ssim::Sim Class Reference

a generic discrete-event sequential simulator More...

#include <ssim.h>

List of all members.

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


Detailed Description

a generic discrete-event sequential simulator

This class implements a generic discrete-event sequential simulator. Sim maintains and executes a time-ordered schedule of actions (or discrete events).


Member Function Documentation

void ssim::Sim::advance_delay Time    [inline, static]
 

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);
      }
  };

See also:
Sim::clock()

void ssim::Sim::clear   [static]
 

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.

Time ssim::Sim::clock   [inline, static]
 

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;
  }

See also:
advance_delay(Time)

ProcessId ssim::Sim::create_process Process  ,
char    mode = 0
[static]
 

creates a new process

creates a new process with the given Process object. mode specifies the execution flags of the process. If the P_SEQUENTIAL flag is set, then the process will process one event at a time with respect to the simulation virtual time, otherwise (default) the actions of this process will be considered reentrant and may be executed in parallel. By default, the simulator discards the events signalled to a P_SEQUENTIAL process while that process is busy executing other actions. The P_QUEUEING flag can be set to instruct the simulator to queue those events. In this case, the simulator will deliver signals to that process as the process is available to respond to them.

void ssim::Sim::set_timeout Time    [inline, static]
 

sets a timeout for the current process

Schedules the execution of process_timeout() on the current process after the given amount of (virtual) time.

int ssim::Sim::signal_event const Event  ,
ProcessId   ,
Time   
[inline, static]
 

signal an event to the given process at the given time

See also:
Process::process_event(const Event * msg);

int ssim::Sim::signal_event const Event  ,
ProcessId   
[inline, static]
 

signal an event to the given process

Signal an event to the given process. The response is scheduled for the current time.

See also:
Process::process_event(const Event * msg);

ProcessId ssim::Sim::this_process   [inline, static]
 

returns the current process

Example:

  void SimpleProcess::process_event(const Event *e) {
      cout << "my process id is: " << Sim::this_pocess() << endl;
  }


The documentation for this class was generated from the following file:
Copyright © 2002 University of Colorado.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". This documentation is authored and maintained by Antonio Carzaniga