|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectLogicalProcess
public abstract class LogicalProcess
This class represents a logical processe that communicates with other logical processes by exchanging timestamped messages. LPs cannot "spontaneously" begin new computations without first receiving a message.
If an LP receives a "straggler" message with timestamps smaller than that its LVT(local virtual time), it rolls back to its LVT and reprocessed (after the straggler) in timestamp order. Each message sent by a rolled back computation is cancelled by sending an anti-message that annihilates the original message. A received anti-message will also cause a rollback if the cancelled message has already been processed.
This is an abstract class. The simulation application programmer needs to implement the abstract methods specified in this class. All such methods are prefixed "app" for ease of recognition.
Version 1.5 changes monitoring/steering yet again. It also adapts the class to the new multi-threaded design (in which the PE scheduling loop is a separate thread from the PE communication loop). As a result, this class (which is handled entirely by the scheduling loop) handles much less of the communication work than earlier versions did.
Version 1.6 changes the format of monitoring/steering slightly (using Strings instead of Objects).
Version 1.7 added a few abstract methods for application programmers to implement. These methods are needed for state-saving and rollback by the kernel.
Field Summary | |
---|---|
static java.lang.String |
ALL_LPS
Reserved APPid indicating a message to be broadcast to every LP rather than sent to a single specific LP. |
(package private) java.lang.String |
APPid
Unique application-assigned identifier of this LP |
java.lang.String |
configData
Configuration data string. |
protected int |
currentTime
Local virtual time(LVT) for this LP. |
protected int |
lastTime
Value of currentTime the previous time runLP(Message) was called. |
(package private) int |
LPid
Unique numeric identifier assigned to this LP by the system. |
(package private) java.lang.String |
myname
Unique application-assigned full name of this LP |
(package private) int |
PEid
Unique numeric identifier for the PE where this LP resides; for debugging purposes |
(package private) SchedulingLoop |
scheduler
SchedulingLoop that this LP can access; it's declared transient so it won't be serialized and copied each time this LP's state is saved |
Constructor Summary | |
---|---|
LogicalProcess()
|
Method Summary | |
---|---|
abstract void |
appFinalizeLP()
Terminates LP and displays simulation statistics. |
abstract java.util.List<java.lang.String> |
appGetMonitorable()
Returns a List of Strings describing all application-specific monitorable parameters of this LP, each in the form "paramName, paramType". |
abstract java.lang.String |
appGetState(java.lang.String name)
Method to get the value of a given application-level monitorable variable. |
abstract java.util.List<java.lang.String> |
appGetSteerable()
Returns a List of Strings describing all application-specific steerable parameters of this LP, each in the form "paramName, paramType". |
abstract boolean |
appInitializeLP()
Initializes the LP state and sends out initial message(s) if necessary. |
abstract void |
appRunLP(java.lang.Object content,
java.lang.String sender)
Handles events according to the specific requirements of the simulation application. |
abstract LogicalProcess |
appSavingLPState()
Save LP state, for monitoring-steering purpose |
abstract void |
appSetConfigData(java.lang.String cdata)
Application-specific configuration. |
abstract void |
appSetLPState(LogicalProcess lp)
Application LP sets LP state |
abstract java.lang.String |
appSetState(java.lang.String name,
java.lang.String val)
Method to set the value of a given application-level monitorable variable. |
abstract java.lang.String |
appToString()
Returns a string representation of the application lp; for debugging purpose |
void |
finalizeLP()
Invokes application-specific termination then does any needed generic cleanup. |
java.lang.String |
getAPPid()
Returns the application-assigned id of this LP. |
int |
getCurrentTime()
Returns the current simulation time of this LogicalProcess. |
int |
getLID()
Returns the LP id. |
java.util.List<java.lang.String> |
getMonitorable()
Returns a List of Strings describing all monitorable parameters of this LP, each in the form "paramName, paramType". |
java.lang.String |
getName()
Returns the name of this LP. |
int |
getPID()
Returns PE id where this LP resides. |
java.lang.String |
getState(java.lang.String name)
Method to get the value of a given monitorable variable. |
java.util.List<java.lang.String> |
getSteerable()
Returns a List of Strings describing all steerable parameters of this LP, each in the form "paramName, paramType". |
boolean |
initializeLP()
Performs generic initialization (if any) then invokes application-specific initialization. |
(package private) void |
rollback(LogicalProcess lpState,
int rbtime)
Rolls back to the the specified time point and restore the state of this LP |
void |
runLP(Message msg)
Handles any events that need to occur before or after any given invocation of appRunLP(java.lang.Object, java.lang.String) . |
(package private) void |
savingLPState(LogicalProcess lp)
Saves the state of this LP |
void |
sendSimMessage(java.lang.Object content,
int timeInc,
int targetLPid)
Informs the SchedulingLoop of a new outgoing simulation message. |
void |
sendSimMessage(java.lang.Object content,
int timeInc,
java.lang.String targetAPPid)
Informs the SchedulingLoop of a new outgoing simulation message. |
void |
setAppID(java.lang.String aid)
Sets the application-specific short id for this LP. |
void |
setConfigData(java.lang.String cdata)
Stores the application-specific data used for configuration and passes it on to the application to apply. |
void |
setEndOfSimFlag()
Sets the end-of-sim flag so the simulation will stop. |
void |
setLID(int lid)
Sets the LP id for this LP. |
(package private) void |
setLPState(LogicalProcess lp)
Sets the state of this LP to the state of the LP passed in as parameter |
void |
setName(java.lang.String n)
Sets the long name of this LP. |
void |
setPID(int pid)
Sets the PE id where the LP resides. |
void |
setScheduler(SchedulingLoop sl)
Assigns the SchedulingLoop for this LP. |
java.lang.String |
setState(java.lang.String name,
java.lang.String val)
Method to set the value of a given steerable variable. |
java.lang.String |
toString()
Provides a String summarizing this LogicalProcess. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ALL_LPS
int PEid
int LPid
java.lang.String APPid
java.lang.String myname
public java.lang.String configData
protected int currentTime
runLP(Message)
is called to match the timestamp of the incoming
Message
. Subclasses may make other changes to this,
but generally should not need to!
protected int lastTime
currentTime
the previous time runLP(Message)
was called.
Again, automatically updated by runLP; subclasses may make other
changes to it, but only with very good reason.
transient SchedulingLoop scheduler
Constructor Detail |
---|
public LogicalProcess()
Method Detail |
---|
void savingLPState(LogicalProcess lp)
void setLPState(LogicalProcess lp)
void rollback(LogicalProcess lpState, int rbtime)
lpState
- LogicalProcess that contains the saved state of the LPpublic abstract void appSetLPState(LogicalProcess lp)
lp
- LogicalProcess containing the state information; the application
program decides what state information need to be storedpublic abstract LogicalProcess appSavingLPState()
public abstract java.lang.String appToString()
public void setEndOfSimFlag()
public final void sendSimMessage(java.lang.Object content, int timeInc, java.lang.String targetAPPid)
content
- The contents of the simulation message.timeInc
- the time increment assigned by the sender(@since 1.7)targetAPPid
- the APPid
of the LP the message should go to.public final void sendSimMessage(java.lang.Object content, int timeInc, int targetLPid)
content
- The contents of the simulation message.timeInc
- the time increment assigned by the sender(@since 1.7)targetLPid
- int the LPid of the receiverpublic void setScheduler(SchedulingLoop sl)
SchedulingLoop
for this LP.
sl
- SchedulingLoop to control this LP.public int getPID()
public void setPID(int pid)
pid
- int representing the PE id.public int getLID()
public void setLID(int lid)
lid
- int representing the LP id.public java.lang.String getAPPid()
public void setAppID(java.lang.String aid)
aid
- String representing the application-specific id for this LP.public java.lang.String getName()
public void setName(java.lang.String n)
n
- String, the long name of this LP.public int getCurrentTime()
public final void setConfigData(java.lang.String cdata)
cdata
- String representing the data that are used for configuration.public abstract void appSetConfigData(java.lang.String cdata)
cdata
- String representing configuration data.public final java.util.List<java.lang.String> getMonitorable()
appGetMonitorable()
to
get application-specific parameters.
Monitorable parameters are:
public abstract java.util.List<java.lang.String> appGetMonitorable()
public final java.util.List<java.lang.String> getSteerable()
appGetSteerable()
to
get application-specific parameters.
Steerable parameters include:
public abstract java.util.List<java.lang.String> appGetSteerable()
public final java.lang.String getState(java.lang.String name)
appGetState(java.lang.String)
.
name
- The name of the variable to monitor
public abstract java.lang.String appGetState(java.lang.String name)
name
- The name of the variable to monitor
public final java.lang.String setState(java.lang.String name, java.lang.String val)
appSetState(java.lang.String, java.lang.String)
.
name
- The name of the variable to steerval
- The value to assign to the variable
public abstract java.lang.String appSetState(java.lang.String name, java.lang.String val)
name
- The name of the variable to steerval
- The value to assign to the variable
public final boolean initializeLP()
public abstract boolean appInitializeLP()
public final void runLP(Message msg)
appRunLP(java.lang.Object, java.lang.String)
. This includes updating the local simulation time
before invoking appRunLP.
msg
- Message object received from another LP.public abstract void appRunLP(java.lang.Object content, java.lang.String sender)
content
- The object associated with the new event.sender
- The APPid
of the LP the event came from.public final void finalizeLP()
public abstract void appFinalizeLP()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |