Class PE

java.lang.Object
  extended by PE
All Implemented Interfaces:
java.lang.Runnable

public class PE
extends java.lang.Object
implements java.lang.Runnable

This class represents the physical processors involved in the time warp simulation engine.

Version:
1.7 (07/2006)
Author:
Yin Xiong

Field Summary
(package private)  java.util.concurrent.PriorityBlockingQueue<Message> cancelQ
          The queue that holds messages that have been cancelled.
(package private)  Flag eosFlag
          Flag for end of sim
(package private)  java.util.concurrent.PriorityBlockingQueue<Message> eventQ
          The queue that holds the processed and unprocessed events for LPs mapped to this PE.
(package private)  java.util.concurrent.PriorityBlockingQueue<Message> freeQ
          The queue that holds the events whose memeory is free to reclaim.
(package private)  GlobalNameServer gns
          The GlobalNameServer
(package private)  int GVT
          The most recent GVT
(package private)  int id
          The id of this PE.
(package private)  LocalNameServer localNameServer
          The LocalNameServer in charge of routing messages.
(package private)  MessagePool msgPool
          The message pool where all messages are stored
(package private)  SchedulingLoop schedulingLoop
          The scheduler that schedules events for this PE.
(package private)  java.util.concurrent.PriorityBlockingQueue<Message> sendQ
          The queue that holds the outgoing messages.
(package private)  int sleepTime
          Sleep time
 
Constructor Summary
PE(int peid, MessagePool msgp, Flag ef, Flag gf, int gc)
          Constructs a new PE instance.
 
Method Summary
 void addLP(LogicalProcess lp)
          Adds a LP into LPs.
 void createLPs(int pid, int lid, java.lang.String appid, java.lang.String appName, java.lang.String className, java.lang.String dat)
          Create LPs in the specified subclass.
 void dumpLNS()
          Display the contents of the routing table.
 void finalizeLPs()
          Finalizes LPs by invoking finalizeLP method provided by subclasses of LogicalProcess.
(package private)  void finalizePE()
           
 int getID()
          Returns the id of the PE.
 LogicalProcess getLPByID(int lpid)
          Gets the LP by its id.
 java.util.Vector getRoutingTable()
          Returns the routing table.
 void initLPs()
          Initialize LPs by invoking initializeLP method provided by subclasses of LogicalProcess.
 void processCanQ()
          Places AntiMessages in CanQ.
(package private)  void processEvents()
          Processes events.
(package private)  void processQs()
          Processes the queues.
 void receiveMsg()
          Receives messages sent to this PE.
 void run()
          Runs the PE(processing events).
 void sendMessages()
          Checks the sendQ and sends message if any.
 void setGNS(GlobalNameServer g)
          Sets the global name server for this PE.
 void setID(int theID)
          Sets the id for the PE (dummy method).
 void setLNS(LocalNameServer lns)
          Sets the local name server for this PE.
 void setSleepTime(int st)
          set the sleep time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

int id
The id of this PE.


eosFlag

Flag eosFlag
Flag for end of sim


GVT

int GVT
The most recent GVT


sleepTime

int sleepTime
Sleep time


msgPool

MessagePool msgPool
The message pool where all messages are stored


localNameServer

LocalNameServer localNameServer
The LocalNameServer in charge of routing messages.


gns

GlobalNameServer gns
The GlobalNameServer


cancelQ

java.util.concurrent.PriorityBlockingQueue<Message> cancelQ
The queue that holds messages that have been cancelled. When a processor wishes to cancel a message, it enqueues the message being cancelled into this queue. Logically, each message enqueued in this queue can be viewed as an anti-message, however, it is the message itself rather than an explicit anti-message that is enqueued. Access this queue is synchronized with locks.


sendQ

java.util.concurrent.PriorityBlockingQueue<Message> sendQ
The queue that holds the outgoing messages. Messages are placed into this by the Scheduler and the sender(main thread) will come here to get the outgoing message and send it out. A copy is kept in this queue, but its sign is changed from positive to negative.


eventQ

java.util.concurrent.PriorityBlockingQueue<Message> eventQ
The queue that holds the processed and unprocessed events for LPs mapped to this PE. Each processed event has pointers to messages scheduled by the computation associated with this event and pointer to state vector information to allow event computation to roll back.


freeQ

java.util.concurrent.PriorityBlockingQueue<Message> freeQ
The queue that holds the events whose memeory is free to reclaim.


schedulingLoop

SchedulingLoop schedulingLoop
The scheduler that schedules events for this PE.

Constructor Detail

PE

public PE(int peid,
          MessagePool msgp,
          Flag ef,
          Flag gf,
          int gc)
Constructs a new PE instance. Sets the id of the PE to peid.

Parameters:
peid - int the id of the PE, i.e. the id of this process in MPI.comm.
Method Detail

setSleepTime

public void setSleepTime(int st)
set the sleep time


run

public void run()
Runs the PE(processing events). This is the communication thread that send and receive messages.

Specified by:
run in interface java.lang.Runnable

finalizePE

void finalizePE()

receiveMsg

public void receiveMsg()
Receives messages sent to this PE.


sendMessages

public void sendMessages()
Checks the sendQ and sends message if any.


processQs

void processQs()
Processes the queues.


processEvents

void processEvents()
Processes events. It takes out each message in SchedulingLoop's outgoing queue, finds out the routing information by application-specified id of the destination or the LP id of the destination, consults the local name server or the global name server (in case local name server does not have the info) for the routing information. It then puts the message into the sendQ for sending out.


processCanQ

public void processCanQ()
Places AntiMessages in CanQ. These are events that have been scheduled by other events. They are removed and deleted.


createLPs

public void createLPs(int pid,
                      int lid,
                      java.lang.String appid,
                      java.lang.String appName,
                      java.lang.String className,
                      java.lang.String dat)
Create LPs in the specified subclass.

Parameters:
pid - int the id of the PE where the LP resides.
lid - int the LP id assigned by the system.
appid - String the application-assigned id of the instance.
appName - String the application-assigned name of the instance.
className - String the name of the instance.
dat - String the configuration data provided by application.

getLPByID

public LogicalProcess getLPByID(int lpid)
Gets the LP by its id.

Parameters:
lpid - int the LP id.

setGNS

public void setGNS(GlobalNameServer g)
Sets the global name server for this PE.


setLNS

public void setLNS(LocalNameServer lns)
Sets the local name server for this PE.


dumpLNS

public void dumpLNS()
Display the contents of the routing table.


initLPs

public void initLPs()
Initialize LPs by invoking initializeLP method provided by subclasses of LogicalProcess.


finalizeLPs

public void finalizeLPs()
Finalizes LPs by invoking finalizeLP method provided by subclasses of LogicalProcess.


getRoutingTable

public java.util.Vector getRoutingTable()
Returns the routing table.


addLP

public void addLP(LogicalProcess lp)
Adds a LP into LPs.


getID

public int getID()
Returns the id of the PE.


setID

public void setID(int theID)
Sets the id for the PE (dummy method).

Parameters:
theID - int representing the value that the PE's id will be set to.