|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSchedulingLoop
public class SchedulingLoop
This class provides the simulation engine logical process scheduling loop. This
loop runs in its own thread in parallel with the communication thread
of the PE. After instantiation, this class should have one or more
LogicalProcesses added (by createLP
) before the thread is
started.
Requires Java 5.0 due to use of the
PriorityBlockingQueue
class and others.
Field Summary | |
---|---|
(package private) java.util.Vector<Message> |
antiMsgsIn
|
(package private) java.util.Vector<Message> |
antiMsgsOut
|
boolean |
done
Very primitive way of stopping the run loop: set this to true. |
(package private) Flag |
eosFlag
The flag indicating the end of sim |
(package private) java.util.Vector<Message> |
eventQueue
|
(package private) int |
GVT
The most recent GVT |
(package private) int |
gvtClock
The frequency that GVT should be computed |
(package private) Flag |
gvtFlag
Flag for computing GVT |
(package private) int |
id
The id of the parent PE of this scheduler. |
java.util.concurrent.PriorityBlockingQueue<Message> |
incoming
Shared priority queue containing incoming Message s from the
communication thread. |
(package private) java.util.List<LogicalProcess> |
LPs
Local list storing all LogicalProcesses managed by this SchedulingLoop. |
(package private) java.util.Vector<LogicalProcess> |
lpStates
The queue that store the saved LP state |
private java.util.List<java.util.SortedSet<MonitorNode>> |
monitoring
Local list storing sorted sets (one per LP) of current and future monitoring commands. |
java.util.concurrent.PriorityBlockingQueue<Message> |
outgoing
Shared priority queue containing outgoing Message s to the
communication thread. |
java.util.PriorityQueue<Message> |
simMessages
Local priority queue storing simulation messages yet to be handled. |
private java.util.List<java.util.SortedSet<SteerNode>> |
steering
Local list storing sorted sets (one per LP) of current and future steering commands. |
Constructor Summary | |
---|---|
SchedulingLoop(int pid)
Constructs a new PE instance. |
Method Summary | |
---|---|
(package private) void |
annihilateMsg(Message m)
Annihilates the positive message who has received a matching anti-message. |
void |
applyMonitoring(int index)
Applies any scheduled monitoring of a single LP. |
void |
applySteering(int index)
Applies any scheduled steering to the specified LP. |
int |
computeLocalMin()
Computes the local minimum timestamp using Samadi's algorithm which dependes on acknowledgement for each and every message sent |
void |
createLP(int pid,
int LPid,
java.lang.String APPid,
java.lang.String name,
java.lang.String className,
java.lang.String data)
Creates a new LogicalProcess of the specified type and adds it to the list of LPs managed by this run loop. |
LogicalProcess |
getLPByAPPid(java.lang.String appid)
Locates one of the LPs managed by this scheduling loop, based on its APPid. |
int |
getLPIndexByAPPid(java.lang.String appid)
Finds the list index of a given LP (position associated with it in LPs , monitoring , and steering ) based on its
APPid. |
int |
getLPIndexByLPid(int lpid)
Finds the list index of a given LP (position associated with it in LPs , monitoring , and steering ) based on its
LP. |
(package private) boolean |
isMsgCanceled(Message m)
|
void |
processIncoming()
Reads incoming messages from the communication thread and, based on their Message.MsgType places them in the appropriate data structures for
later processing. |
(package private) Message |
rollBack(LogicalProcess theLP,
int rbtime)
Rolls back to the time specified by rbtime and returns the first message immediately after the rollback. |
void |
run()
Method required by Runnable interface; called when the thread is first created. |
int |
runOneLP()
Calls LogicalProcess.runLP(Message) for the first Message in the
simMessages queue. |
Message |
sendAntiMsgs(int lp,
int rbtime)
Sends out anti-messages. |
void |
sendMessage(Message msg)
Places the specified (partly-formatted) Message into the outgoing message queue for the communication thread to send out. |
(package private) void |
setFlags(Flag ef,
Flag gf)
Sets the flags. |
(package private) void |
setGVTClock(int gc)
Sets the GVT clock. |
void |
updateGVT(int newGVT)
Updates GVT and do fossil collection |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
int id
Flag eosFlag
Flag gvtFlag
int GVT
int gvtClock
java.util.Vector<LogicalProcess> lpStates
public boolean done
public java.util.concurrent.PriorityBlockingQueue<Message> incoming
Message
s from the
communication thread.
public java.util.concurrent.PriorityBlockingQueue<Message> outgoing
Message
s to the
communication thread. Note that the addressing of these Messages are
not likely to be fully specified, since this class does not have access
to a GlobalNameServer. In general, the communication thread should
expect to have to use Message.senderAPPid
and
Message.receiverAPPid
to look up the LPid and PE of the sender
and receiver. The communication thread is also expected to recognize
and handle the case where receiverAPPid ==
LogicalProcess.ALL_LPS
.
java.util.List<LogicalProcess> LPs
public java.util.PriorityQueue<Message> simMessages
java.util.Vector<Message> antiMsgsOut
java.util.Vector<Message> antiMsgsIn
java.util.Vector<Message> eventQueue
private java.util.List<java.util.SortedSet<MonitorNode>> monitoring
private java.util.List<java.util.SortedSet<SteerNode>> steering
Constructor Detail |
---|
public SchedulingLoop(int pid)
pid
- int the id of the PE, i.e. the id of this process.Method Detail |
---|
void setGVTClock(int gc)
gc
- int the frequency that GVT will be computed.void setFlags(Flag ef, Flag gf)
ef
- Flag end-of-program flaggf
- Flag flag indicating it's time to compute GVTpublic int computeLocalMin()
local minimum timestamp = the minumum timestamp among
public void updateGVT(int newGVT)
newGVT
- int the new GVT broadcast by the controllerpublic void sendMessage(Message msg)
msg
- Message to send, assumed to have correctly filled senderAPPid,
senderLP, and receiverAPPid, but not necessarily senderPE, receiverLP,
or receiverPE (which are not likely to be known by this class or by any
LogicalProcess, but should be known by the messaging thread).public Message sendAntiMsgs(int lp, int rbtime)
public void run()
done
is set to true
.
run
in interface java.lang.Runnable
public int runOneLP()
LogicalProcess.runLP(Message)
for the first Message
in the
simMessages
queue. Messages directed to a LogicalProcess not
owned by this SchedulingLoop are assumed to have been misdelivered, and
are placed in outgoing
.
Message rollBack(LogicalProcess theLP, int rbtime)
theLP
- a LogicalProcess that needs to rollbackrbtime
- int the time the LP will rollback tovoid annihilateMsg(Message m)
boolean isMsgCanceled(Message m)
m
- Message to be checkedpublic void processIncoming()
Message.MsgType
places them in the appropriate data structures for
later processing.
Message.MsgType.SIM_REGULAR
- placed in simMessages
.
Message.MsgType.SYSTEM_MONITOR
- placed in monitoring
.
Message.MsgType.SYSTEM_STEER
- placed in steering
.
public void applyMonitoring(int index)
index
- The storage index of the LP to monitor.public void applySteering(int index)
index
- The storage index of the LP to steer.public int getLPIndexByLPid(int lpid)
LPs
, monitoring
, and steering
) based on its
LP.
lpid
- The LPid to look for
public int getLPIndexByAPPid(java.lang.String appid)
LPs
, monitoring
, and steering
) based on its
APPid.
appid
- The APPid to look for (case insensitive)
public void createLP(int pid, int LPid, java.lang.String APPid, java.lang.String name, java.lang.String className, java.lang.String data)
pid
- The numerical ID of the PE where this LP residesLPid
- The numerical ID of the LPAPPid
- The application-assigned ID of the LPname
- The application-assigned full name of the LPclassName
- Name of LogicalProcess subclass to createdata
- Configuration data to pass into the LPLogicalProcess
public LogicalProcess getLPByAPPid(java.lang.String appid)
appid
- The APPid to look for (case insensitive)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |