|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--scorej.OmarClock
|
+--scorej.NonSimulationClock
Non Simulation Mode clock. This clock is meant to be used for simulations that want to run in real (wall-clock) time as opposed to having a clock process manage time. The clock thread, which was the central controlling thread for SimulationClocks, basically just does a Thread.yield() here. The main features of the non-simulation clock are:
S.sleep() does a Thread.sleep().
Signals are delivered by a signal processor thread asynchronously. Once delivered, they are removed. Thus, it is up to the programmer to ensure that any waitForSignals are active before the corresponsing sendSignal gets sent. This can be tricky in a multi-threaded environment such as this one. For example, consider the following code snippet:
S.join(Invocation.callStatic("waitForSignal", "S", s1),
Invocation.callStatic("sendSignal","S", s1))
It is undetermined which thread (waitForSignal, or sendSignal) will execute
first. With the NonSimulation clock, if the sendSignal goes off before the
waitForSignal has executed long enough to create and register the SignalWait
object, the waitForSignal will miss the send of s1.
SignalWaitQueues are a solution to this problem.
SignalWaitQueue| Nested Class Summary |
| Nested classes inherited from class scorej.OmarClock |
OmarClock.Process, OmarClock.StatusObj |
| Field Summary |
| Fields inherited from class scorej.OmarClock |
_clockSync, _isSleepingSync, _pausedSync, _pauseTime, _realTime, _realTimeFactor, _resourceMap, _sigProc, _sleeping, _stateChangedSync, _status, _statusTable, _statusTableSync, _thread, _time, _zeroTime, DEAD, INITIALIZED, KILLED, PAUSED, RUNNING, SUSPENDED, TRANSITION, UNINITIALIZED, WAITING_FOR_FUTURE, WAITING_FOR_RESOURCE, WAITING_FOR_SIGNAL, WORKING |
| Constructor Summary | |
NonSimulationClock()
No argument constuctor. |
|
NonSimulationClock(double realTimeFactor)
|
|
| Method Summary | |
double |
getTime()
Return the total time elapsed in seconds since the clock started. |
void |
killClock()
Override of killClock. |
void |
run()
Run method is basically a no-op once the clock is actually started. |
void |
sleep(java.lang.Thread t,
double sleepTime)
Thread sleeps for sleepTime real-time seconds. |
protected void |
startSignalProcessor()
Signal processor is a separate thread that processes signals in parallel to the clock's execution. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public NonSimulationClock(double realTimeFactor)
realTimeFactor - double = factor which sleeps are divided by.
For example, realTimeFactor = 2 will cause all sleeps to be half as long.public NonSimulationClock()
| Method Detail |
protected void startSignalProcessor()
public void killClock()
killClock in class OmarClock
public void sleep(java.lang.Thread t,
double sleepTime)
sleep in class OmarClockt - The thread that wants to sleep.sleepTime - How long the thread wants to sleep forpublic void run()
run in interface java.lang.Runnablerun in class OmarClockpublic double getTime()
diff = (current system time in millis) - (system time in millis when the clock started) diff * (1000 / real time factor)
getTime in class OmarClock
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||