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 a physical processor involved in the time warp simulation engine. A PE could have multiple LPs running on it.

Version:
2.0 (10/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 flag
          Flag for end of sim
(package private)  java.util.concurrent.PriorityBlockingQueue<Message> freeQ
          The queue that holds the events whose memeory is free to reclaim.
(package private)  GNSInterface gns
          The global name server
(package private)  int GVT
          The most recent GVT
(package private)  LocalNameServer localNameServer
          The LocalNameServer in charge of routing messages.
(package private)  java.util.Vector<LPConfigInfo> lpConfigInfo
          The LP configuration information
(package private)  int myID
          The id of this PE.
(package private)  java.lang.String myIP
          The ip of the machine where the PE is running
(package private)  java.lang.String myMachineName
          The name of the machine where the PE is running
(package private)  Peer[] peers
          an array of Peer objects serving as the handles of the remote methods
(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)  java.lang.String serverName
          the name of the GNS server
(package private)  int sleepTime
          Sleep time
 
Constructor Summary
PE(java.lang.String sv, int numPEs)
           
 
Method Summary
 void addLP(LogicalProcess lp)
          Adds a LP into LPs.
(package private)  int computeLocalMin()
          Computes the local minimum timestamp
(package private)  void connectToGNS()
          Connects this PE to the GNS server, receives LP information and create LPs accordingly.
(package private)  void createLP(LPConfigInfo lpinfo)
          Create LPs according to the LP configuration information obtained from the GNS(Global Name Server).
(package private)  void doSleep(int sleeptime)
          Puts the current thread to sleep for sleeptime miliseconds.
 void doYield()
          Yields the current thread.
(package private)  void finalizeLPs()
          Finalizes LPs by invoking finalizeLP method provided by subclasses of LogicalProcess.
(package private)  void finalizePE()
          Finalizes the PE by checking and setting the end-of-sim flag.
 int getID()
          Returns the id of the PE.
(package private)  LogicalProcess getLPByID(int lpid)
          Gets the LP by its id.
(package private)  void initLPs()
          Initialize LPs by invoking initializeLP method provided by subclasses of LogicalProcess.
static void main(java.lang.String[] args)
          The main function for this PE
(package private)  void processCanQ()
          Places AntiMessages in CanQ.
(package private)  void processEvents()
          Processes events.
(package private)  void processQs()
          Processes the queues.
(package private)  void rmiSendMessages()
          Sends messages by invoking the remote method receiveMsg(Message msg) on the receiver machine.
 void run()
          Runs the PE(processing events).
(package private)  void setEOSflag()
          Sets the end of sim flag so the PE will stop.
 void setID(int theID)
          Sets the id for the PE (dummy method).
 void setSleepTime(int st)
          Sets the sleep time for this thread; sleep time is specified by the user at the command line.
(package private)  void updateGVT(int newGVT)
          Updates GVT and does fossil collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

peers

Peer[] peers
an array of Peer objects serving as the handles of the remote methods


myID

int myID
The id of this PE.


myMachineName

java.lang.String myMachineName
The name of the machine where the PE is running


myIP

java.lang.String myIP
The ip of the machine where the PE is running


lpConfigInfo

java.util.Vector<LPConfigInfo> lpConfigInfo
The LP configuration information


GVT

int GVT
The most recent GVT


sleepTime

int sleepTime
Sleep time


gns

GNSInterface gns
The global name server


localNameServer

LocalNameServer localNameServer
The LocalNameServer in charge of routing messages.


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.


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.


flag

Flag flag
Flag for end of sim


serverName

java.lang.String serverName
the name of the GNS server

Constructor Detail

PE

public PE(java.lang.String sv,
          int numPEs)
Method Detail

setEOSflag

void setEOSflag()
Sets the end of sim flag so the PE will stop.


connectToGNS

void connectToGNS()
            throws java.rmi.RemoteException
Connects this PE to the GNS server, receives LP information and create LPs accordingly.

Throws:
java.rmi.RemoteException

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()
Finalizes the PE by checking and setting the end-of-sim flag.


rmiSendMessages

void rmiSendMessages()
Sends messages by invoking the remote method receiveMsg(Message msg) on the receiver machine.


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.


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
The main function for this PE

Throws:
java.io.IOException

setSleepTime

public void setSleepTime(int st)
Sets the sleep time for this thread; sleep time is specified by the user at the command line. If not specified, it is set to 0


doYield

public void doYield()
Yields the current thread.


doSleep

void doSleep(int sleeptime)
Puts the current thread to sleep for sleeptime miliseconds.

Parameters:
sleeptime - int the length for the sleep in miliseconds.

computeLocalMin

int computeLocalMin()
Computes the local minimum timestamp

Returns:
the local minimum timestamp

local minimum timestamp = the minumum timestamp among

  • all unprocessed events
  • all unacknowledged messages and anti-messages it has sent
  • all marked acknowledgement messages it has received since it last received a new GVT value
the PE sets a flag indicating it's in find mode

updateGVT

void updateGVT(int newGVT)
Updates GVT and does fossil collection.

Parameters:
newGVT - int the new GVT broadcast by the controller

processQs

void processQs()
Processes the queues.


processCanQ

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


createLP

void createLP(LPConfigInfo lpinfo)
Create LPs according to the LP configuration information obtained from the GNS(Global Name Server).

Parameters:
lpinfo - LPConfigInfo object containing the lp configuration information

getLPByID

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

Parameters:
lpid - int the LP id.

initLPs

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


finalizeLPs

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


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.