next up previous contents
Next: The CommManager class Up: The GVTManager class Previous: calculateGVT

recvMsg

The GVTManager has the ability to accept messages from the CommManager on the same LP as it, and the ability to accept TerminateMsgs from the simulation objects local to the LP. As with the CommManager class, the method recvMsg has been overloaded to accept any type of message that the GVTManager class is allowed to accept, which include: LGVTMsgs, LowerLGVTMsgs, NewGVTMsgs, LPAckMsgs, GVTAckMsgs, CheckIdleMsgs, DummyMsgs, and DummyRequestMsgs. These message types are discussed in detail in the section on the CommManager class. Note that only the central GVT manager should receive LGVTMsgs and LowerLGVTMsgs, and should also be the only one to send NewGVTMsgs.

Here is the class declaration for the GVTManager class: (Please note that this particular GVTManager implements the pGVT algorithm)

class GVTManager : public BasicTimeWarp {
  friend class LogicalProcess;
  friend class OfcManager;
public:
  GVTManager();
  ~GVTManager();
  void initialize(ObjectRecord*, CommManager*,int, int, int, int); 
  // the array of simObjects
  // the address of the commManager
  // the id of this lp
  // the total number of objects
  // the number of local guys
  // the number of LPs
  
  void recvMsg(LGVTMsg *);
  void recvMsg(LowerLGVTMsg *);
  void recvMsg(newGVTMsg *);
  void recvMsg(LPAckMsg *);
  void recvMsg(GVTAckMsg *);
  void recvMsg(CheckIdleMsg *);
  void recvMsg(DummyMsg *);
  void recvMsg(DummyRequestMsg *);

  virtual void calculateLGVT(); // calculate the local estimate of GVT
                                // also figures out if the LP is idle or not...

  void calculateGVT();   // calculate the actual value of gVT.  This
                         // function should only be called in the function
                         // that is responsible for the calculation of the
                         // "real" gVT.  It is assumed that LP 0 is 
                         // responisble for gVT calculation

  VTime getGVT();         // return GVT to the caller
  void setGVT(VTime);     // set a new internbal value for gVT
  VTime getLGVT();        // return local estimate to the caller
  void setLGVT(VTime);    // set the local estimate of GVT
  
  void sendEvent(LGVTMsg *);
  void sendEvent(newGVTMsg *);
  void sendEvent(CheckIdleMsg *);
  void sendEvent(DummyMsg *);
  void sendEvent(DummyRequestMsg *);
  void sendEvent(TerminateMsg *);

  // All of this stuff is to avoid message acknowledgement
  void msgSendPeek( EventMsg *);
  void msgRecvPeek( EventMsg *);

  // these are here to make the compiler happy (since this class is 
  // derived from BasicTimeWarp)
  void simulate();
  BasicEvent* getEvent();
  void sendEvent(BasicEvent *);
  void recvEvent(BasicEvent *);
  VTime calculateMin();
  void executeProcess();

  ObjectRecord* getArrayHandle(){ return simArray; }

  // the LP sets this flag when all of the local simulation objects have
  // reported that they're idle
  OneShot<bool> lpIdle;
protected:
  virtual void gcollect();

private:
  bool checkIdle();
  void cancelToken(CheckIdleMsg *);
  void passItOn(CheckIdleMsg *);
  void startToken();
  void calcMin();

  ObjectRecord* simArray;  // This is a pointer to the array of 
                           // simulation objects in the LP
  CommManager* commHandle; // our handle to our communication 
                           // manager

  VTime* lGVTArray;               // array of gVT estimates for all LPs
                                  // only valid for LP 0
  bool* idleArray;

  int definedGVT;                 // this is for the "head" GVT guy only -
                                  // it is who set gVT last time

  VTime gVT;                       // global virtual time
  VTime lGVT;                      // our local estimate of gVT

  VTime lastReported;              // the last lGVT value sent to the head
                                  // gVT Manager
  bool lastIdle;                  // our last idle

  int numObjects;                 // the number of objects on our LP
  int totalObjects;               // the total number of simulaiton objects
  int numLPs;                     // the number of logical processes

  VTime* lastTimeSent;  // array of the last times of event messages that
                        // I sent to each LP (and are unacknowleged)

  VTime* lastTimeReceived;  // array of the last
  VTime lowestUnacknowledged;
  SortedList<AckRecord> needAcked;
  int currentToken;
  bool tokenPending;
  bool *dummyPending;
  int noOfGVTToSkip;

};
There are three other GVTManagers, namely MatternGVTManager, GeoOfcManager and ChebyOfcManager.



Philip A. Wilsey
1/26/1998