index previous next 

file name: process.hpp, process.cpp
classification: simulation
contents: abstract class ACProcess
derived from: either class Process (C++SIM), or none
use: the interface class to the simulation process of C++SIM
 

Note: There are two class declarations for ACProcess, one if LINUX_SIM is defined, and one if it is not defined.
 

global items used:

global items defined:

const unsigned long DefaultProcessID: This is the ID of all processes that do not have an own ID. Process IDs are important in pure simulation, where the network needs them to find out the ID of the node that has sent a message. So every process that can cause a message to be sent should have an identifier (which is the nodeID).

const INT32 TICKS2SEC: One second is TICKS2SEC pSOS ticks.
 
#define NO_RESOURCE: The macro is defined if LINUX_SIM is not defined.
 

member variables of ACProcess (LINUX_SIM defined):

unsigned long nodeID_: the ID of the node for which this process works.
 

member functions of ACProcess (LINUX_SIM defined):

ACProcess (unsigned long nodeID = DefaultProcessID): Stores the ID of the node for which the process works.

virtual unsigned long GetNodeID (): Returns the node ID.

virtual void SetNodeID (unsigned long nodeID): Sets or changes the node ID.

void tm_wkafter (INT32 time): Waits for time pSOS-Ticks. This is done by calling Hold() with the appropriate time in seconds.
 

member types and variables of ACProcess (LINUX_SIM not defined):

Note: If LINUX_SIM is not defined, C++SIM is not used and ACProcess does not have a base class. Many functions of the process class of C++SIM have to be simulated. Two static variables currTime and currentProcess are used to keep track of the simulation time and of the currently active process. After startup, the simulation time is set to zero, and the currentProcess to NULL. All functions try to simulate the behaviour of the C++SIM process class as close as possible; of course, context switches etc. are not possible, but for debugging purposes two variables state and assocTime show the state and schedule time of a process, and the functions modify these variables instead.
 

enum EState: the process state. Possible states are Terminated, Suspended, Passive and Scheduled. There is no Active state, since the processes normally are not active if C++SIM is not used.

double assocTime_: the time for which the process is scheduled.
default: 0

static ACProcess *currentProcess_: the currently active process.
default: NULL

static double currTime_: the current simulation time.
default: 0

unsigned long nodeID_: the ID of the node for which this process works.
default: the nodeID parameter of the ctor

EState state_: contains the process state.
default: Passive
 

member functions of ACProcess (LINUX_SIM not defined):

ACProcess (unsigned long nodeID = DefaultProcessID): Sets all members (except the static ones) to their default values.

virtual ~ACProcess(): does nothing.

void Activate (): If the state of the process is Passive, its state is set to Scheduled and assocTime is set to the current simulation time. If the process is not passive, the function has no effect.

virtual void Body(): pure virtual
This function is called by C++SIM, and it should not return. It is the main body of the process.

void Cancel(): sets the state to Passive.

static const ACProcess* current(): Returns a pointer to the currently active process (the value of currentProcess).

static double CurrentTime (): Returns the current simulation time (the value of currTime).

double evtime() const: Returns the time at which the process is scheduled, ie., the value of assocTime.

void Hold (double t): assocTime is incremented by t (in C++SIM, the function deactivates the process and schedules it for a delay t).

EBool idle () const: If the process is scheduled or if it is active (ie., if the currentProcess variable points to it), False is returned. Otherwise, the functions returns True.

virtual unsigned long GetNodeID (): Returns the node ID.

void ReActivate (): If the process is neither Terminated nor Suspended, its state is set to Scheduled and assocTime is set to the current time.

void ReActivateAt (double AtTime = 0): Behaves like ReActive(), but it schedules the process for the absolute time AtTime. If the current simulation time is greater than AtTime, the process is scheduled for the current time.

void ReActivateDelay (double AtTime = 0): Behaves like ReActive(), but it schedules the process for a time AtTime seconds from the current time.

static void SetActiveProcess (ACProcess *process): Sets the active process. Again, the function is needed for debugging and must not be used by any modules except test programs. It only exists if DOS_SIM is defined (debugging is done in Win95).

static void SetCurrentTime (double time): Sets the simulation time. This function has been added for debugging and must not be used by simulation modules. It only exists if DOS_SIM is defined (debugging is done in Win95).

virtual void SetNodeID (unsigned long nodeID): Sets/changes the node ID.

virtual void Suspend(): sets the state to Suspended.

virtual void terminate(): sets the state to Terminated.

void tm_wkafter (INT32 time): The function only exists if PSOS_SIM is not defined and waits for time pSOS-Ticks. This is done by calling Hold() with the appropriate time in seconds. If PSOS_SIM is defined, pSOS+ is used and tm_wkafter() is a system call (which also waits for time pSOS-Ticks).


last modified: Fri Feb 5 18:56:31 1999