DRCL JavaSim API

drcl.comp
Class ARuntime

java.lang.Object
  |
  +--drcl.DrclObj
        |
        +--drcl.comp.ForkManager
              |
              +--drcl.comp.ACARuntime
                    |
                    +--drcl.comp.ARuntime
All Implemented Interfaces:
java.lang.Cloneable, ObjectDuplicable, java.io.Serializable
Direct Known Subclasses:
SMMTSimulator

public class ARuntime
extends ACARuntime

A realization of ACA runtime.

See Also:
AWorkerThread, Serialized Form

Field Summary
protected  int cwf
           
static java.lang.String Debug_Q
           
static java.lang.String Debug_RECYCLE
           
static java.lang.String Debug_STATE
           
static java.lang.String Debug_THREAD
           
static java.lang.String Debug_THREAD_STATE
           
static java.lang.String Debug_WORKFORCE
           
protected  long ltime
           
protected  long nEvents
           
protected  long nLags
           
protected  int nthreadsWaiting
           
protected  FIFOQueue qBufferedTask
          Used to store tasks.
protected  boolean rtEnabled
           
protected  long rtTol
           
protected  long startTime
           
static java.lang.String State_RESETTING
          Transitional state to INACTIVE when system is being reset.
static java.lang.String State_SUSPENDING
          Transitional state to SUSPENDED.
protected  java.lang.ThreadGroup threadGroup
           
protected  FIFOQueue threadPool
           
protected  double time
           
protected  int total
           
protected  long totalThreadRequests
           
protected  drcl.comp.ARuntime.WakeupThread wakeupThread
           
protected  int wf
           
 
Fields inherited from class drcl.comp.ACARuntime
debug, DEFAULT_RUNTIME, logenabled, name, resetting, state, State_INACTIVE, State_RUNNING, State_SUSPENDED, tf, timeScale, timeScaleReciprocal, tr, vStateListener
 
Fields inherited from class drcl.comp.ForkManager
parent, runtime
 
Constructor Summary
ARuntime()
           
ARuntime(java.lang.String name_)
           
 
Method Summary
 void ___PROFILE___()
           
protected  double _getEventRate(long numArrivals_)
           
protected  double _getTime()
          Asynchronized version of getTime(), for diagnosis.
protected  void _stop(boolean block_)
           
 java.lang.String a_info(boolean listWaitingTasks_)
          Asynchronous version of ACARuntime.diag().
protected  void adjustTime()
          Adjust startTime according to wall time and ltime Called when simulation started and resumed.
 void forceReset()
          Forces to reset this runtime.
 int getAvailableWorkforce()
          Returns the amount of available workforce in this runtime.
 double getEfficiencyIndex()
          Returns the efficiency index of thread recycling.
 double getEventEfficiencyIndex(long numberOfArrivalEvents_)
           
 java.lang.Object getEventQueue()
           
 double getEventRate()
          Returns the event processing rate of this runtime.
 int getMaxWorkforce()
          Returns the maximum workforce managed by this runtime.
 long getNumberOfArrivalEvents()
          Returns the number of arrival events.
 int getNumberOfIdleThreads()
          Returns the number of [idle] worker threads in the recycling pool.
 long getNumberOfThreadRequests()
          Returns the number of requests for worker threads.
 int getNumberOfThreadsCreated()
          Returns the number of worker threads being created.
 int getNumberOfWorkingThreads()
          Returns the number of worker threads that are currently executing some tasks.
 long getNumLaggingEvents()
           
 Queue getQ()
           
 double getRTEvaluation()
          Returns the percentage where events are processed in real time (within tolerance specified by setRTTolerance() (not implemented).
 long getRTTolerance()
           
 java.lang.ThreadGroup getThreadGroup()
           
 double getThreadRequestRate()
           
 long getWallTimeElapsed()
          Returns the actual time (in ms) this runtime has run for.
 AWorkerThread getWorkingThread(int index_)
          Returns the worker thread, for diagnosis
protected  AWorkerThread[] getWorkingThreads()
           
protected  AWorkerThread grabOne()
          Grabs a AWorkerThread from recycling pool, creates one if necessary.
 java.lang.String info()
          Returns general information of this runtime.
 boolean isIdle()
          Returns true if the runtime is stopped (inactive or suspended) or running but all working threads are waiting.
 boolean isResetting()
          Returns true if the runtime is in resetting.
 boolean isRTEnabled()
           
 void listThreads()
           
protected  void newTask(Task task_, WorkerThread currentThread_)
          The only way to trigger new tasks to be executed.
protected  AWorkerThread newThread()
          For subclasses to provide its own worker thread class.
protected  void off(ACATimer handle_)
          Cancels a fork event.
 void print(java.lang.String which_, AWorkerThread current_, java.lang.String msg_)
           
 void println(java.lang.String which_, AWorkerThread current_, java.lang.String msg_)
           
protected  void recordTime()
           
protected  void recycle(AWorkerThread thread_)
          Used by AWorkerThread to return itself to the pool.
 void reset()
          The workerpool enters a transitional period when reset() is issued.
 void resume()
          Resumes the system.
 java.lang.String s_info()
          Returns statistics of this runtime.
 java.lang.String s_info(boolean listWaitingTasks_)
          Returns statistics of this runtime.
 void setMaxWorkforce(int value_)
          Set the amount for all.
 void setRTEnabled(boolean value_)
          Can only be set when INACTIVE (not implemented).
 void setRTTolerance(long v_)
           
protected  void setState(java.lang.String new_)
           
 java.lang.String ss_info()
          Synchronized version of s_info().
 java.lang.String sthreads()
           
 java.lang.String swthreads()
          Synchronized version of wthreads().
protected  void systemBecomesIdle(AWorkerThread exe_)
          Subclasses should override this method to handle the event when all workerthreads in the system become either waiting or idle.
protected  void systemBecomesInactive()
          Called when system becomes inactive, that is, no thread is active or all threads are waiting.
 java.lang.String t_info()
           
protected  java.lang.String t_info(java.lang.String prefix_)
           
 java.lang.String tasks()
          Returns information of the task queue.
protected  void threadBecomesWaiting(AWorkerThread exe_)
           
protected  boolean threadRequestsSleeping(AWorkerThread exe_, double time_)
          Subclasses should override this method to handle the event when a workerthread requests to become waiting.
 java.lang.String threads()
          Returns information of the associate thread group.
protected  void threadStateChange(AWorkerThread thread_, java.lang.String oldState_, java.lang.String newState_)
           
protected  void triggerWakeupThread()
           
 java.lang.String wakeupThreadInfo()
           
 java.lang.String wthreads()
          Returns information of working threads.
 
Methods inherited from class drcl.comp.ACARuntime
_openlog, a_info, addDebugLevel, addRunnable, addRunnable, addRunnableAt, addRunnableAt, addStateListener, childManager, containsDebugLevel, debug_info, diag, diag, finalized, getAllDebugLevels, getAllStateListeners, getName, getParent, getState, getTime, getTimeScale, isDebugEnabled, isDebugEnabledAt, isRunning, isStopped, isSuspended, notifyStateListeners, process, reboot, receive, receiveAt, removeDebugLevel, removeStateListener, resumeFor, resumeTo, send, sendAt, setDebugEnabled, setDebugEnabledAt, setDebugLevels, setName, setParent, setRuntime, setTimeScale, stop, stop, stopAt, takeover, takeover, toString, tr_info
 
Methods inherited from class drcl.comp.ForkManager
a_list, getRuntime, info, list, takeover
 
Methods inherited from class drcl.DrclObj
clone, duplicate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Debug_THREAD

public static final java.lang.String Debug_THREAD

Debug_THREAD_STATE

public static final java.lang.String Debug_THREAD_STATE

Debug_WORKFORCE

public static final java.lang.String Debug_WORKFORCE

Debug_Q

public static final java.lang.String Debug_Q

Debug_RECYCLE

public static final java.lang.String Debug_RECYCLE

Debug_STATE

public static final java.lang.String Debug_STATE

State_SUSPENDING

public static final java.lang.String State_SUSPENDING
Transitional state to SUSPENDED.

State_RESETTING

public static final java.lang.String State_RESETTING
Transitional state to INACTIVE when system is being reset.

wf

protected int wf

cwf

protected int cwf

threadPool

protected FIFOQueue threadPool

total

protected int total

totalThreadRequests

protected long totalThreadRequests

startTime

protected long startTime

ltime

protected long ltime

time

protected double time

threadGroup

protected java.lang.ThreadGroup threadGroup

qBufferedTask

protected FIFOQueue qBufferedTask
Used to store tasks.

wakeupThread

protected drcl.comp.ARuntime.WakeupThread wakeupThread

nthreadsWaiting

protected int nthreadsWaiting

rtEnabled

protected boolean rtEnabled

nLags

protected long nLags

nEvents

protected long nEvents

rtTol

protected long rtTol
Constructor Detail

ARuntime

public ARuntime()

ARuntime

public ARuntime(java.lang.String name_)
Method Detail

newTask

protected void newTask(Task task_,
                       WorkerThread currentThread_)
The only way to trigger new tasks to be executed.
Overrides:
newTask in class ACARuntime

setMaxWorkforce

public void setMaxWorkforce(int value_)
Set the amount for all.
Overrides:
setMaxWorkforce in class ACARuntime

getMaxWorkforce

public int getMaxWorkforce()
Returns the maximum workforce managed by this runtime.

getAvailableWorkforce

public int getAvailableWorkforce()
Returns the amount of available workforce in this runtime.

getThreadGroup

public java.lang.ThreadGroup getThreadGroup()

listThreads

public void listThreads()

info

public java.lang.String info()
Returns general information of this runtime.
Overrides:
info in class ACARuntime

ss_info

public java.lang.String ss_info()
Synchronized version of s_info().

s_info

public java.lang.String s_info()
Returns statistics of this runtime.

s_info

public java.lang.String s_info(boolean listWaitingTasks_)
Returns statistics of this runtime.

a_info

public java.lang.String a_info(boolean listWaitingTasks_)
Asynchronous version of ACARuntime.diag().
Overrides:
a_info in class ACARuntime

sthreads

public java.lang.String sthreads()

threads

public java.lang.String threads()
Returns information of the associate thread group.

swthreads

public java.lang.String swthreads()
Synchronized version of wthreads().

wthreads

public java.lang.String wthreads()
Returns information of working threads.

tasks

public java.lang.String tasks()
Returns information of the task queue.

grabOne

protected AWorkerThread grabOne()
Grabs a AWorkerThread from recycling pool, creates one if necessary.

newThread

protected AWorkerThread newThread()
For subclasses to provide its own worker thread class.

recycle

protected void recycle(AWorkerThread thread_)
Used by AWorkerThread to return itself to the pool.

forceReset

public void forceReset()
Forces to reset this runtime.

getWorkingThread

public AWorkerThread getWorkingThread(int index_)
Returns the worker thread, for diagnosis

___PROFILE___

public void ___PROFILE___()

getNumberOfThreadsCreated

public int getNumberOfThreadsCreated()
Returns the number of worker threads being created.

getNumberOfIdleThreads

public int getNumberOfIdleThreads()
Returns the number of [idle] worker threads in the recycling pool.

getNumberOfThreadRequests

public long getNumberOfThreadRequests()
Returns the number of requests for worker threads.

getNumberOfArrivalEvents

public long getNumberOfArrivalEvents()
Returns the number of arrival events.
Overrides:
getNumberOfArrivalEvents in class ACARuntime

getEfficiencyIndex

public double getEfficiencyIndex()
Returns the efficiency index of thread recycling. Calculated by getNumberOfThreadRequests() over getNumberOfThreadsCreated().

getEventEfficiencyIndex

public double getEventEfficiencyIndex(long numberOfArrivalEvents_)

getNumberOfWorkingThreads

public int getNumberOfWorkingThreads()
Returns the number of worker threads that are currently executing some tasks.

getEventRate

public double getEventRate()
Returns the event processing rate of this runtime.
Overrides:
getEventRate in class ACARuntime

_getEventRate

protected double _getEventRate(long numArrivals_)

getThreadRequestRate

public double getThreadRequestRate()

getWorkingThreads

protected AWorkerThread[] getWorkingThreads()

_getTime

protected double _getTime()
Asynchronized version of getTime(), for diagnosis. Subclasses should override this method to provide its own time mapping function.
Overrides:
_getTime in class ACARuntime

adjustTime

protected void adjustTime()
Adjust startTime according to wall time and ltime Called when simulation started and resumed.

recordTime

protected void recordTime()

_stop

protected void _stop(boolean block_)
Overrides:
_stop in class ACARuntime

resume

public void resume()
Resumes the system. The state must advance to RUNNING when this method returns.
Overrides:
resume in class ACARuntime

reset

public void reset()
The workerpool enters a transitional period when reset() is issued. It waits for all the working thread to either finishes the job or goes into sleep. After all the threads finish jobs, it releases all the threads by kill()ing them.

CAUTION: 1. This method is better be executed by a thread that is not created from this worker pool, unless you know what you're doing. 2. Current implementation does not work if a thread executes indefinitely.

Overrides:
reset in class ACARuntime

getWallTimeElapsed

public long getWallTimeElapsed()
Returns the actual time (in ms) this runtime has run for.
Overrides:
getWallTimeElapsed in class ACARuntime

t_info

public java.lang.String t_info()
Overrides:
t_info in class ACARuntime

t_info

protected java.lang.String t_info(java.lang.String prefix_)
Overrides:
t_info in class ACARuntime

setState

protected void setState(java.lang.String new_)
Overrides:
setState in class ACARuntime

isResetting

public boolean isResetting()
Returns true if the runtime is in resetting.

isIdle

public boolean isIdle()
Returns true if the runtime is stopped (inactive or suspended) or running but all working threads are waiting.
Overrides:
isIdle in class ACARuntime

threadStateChange

protected void threadStateChange(AWorkerThread thread_,
                                 java.lang.String oldState_,
                                 java.lang.String newState_)

print

public void print(java.lang.String which_,
                  AWorkerThread current_,
                  java.lang.String msg_)

println

public void println(java.lang.String which_,
                    AWorkerThread current_,
                    java.lang.String msg_)

setRTEnabled

public void setRTEnabled(boolean value_)
Can only be set when INACTIVE (not implemented).

isRTEnabled

public boolean isRTEnabled()

getNumLaggingEvents

public long getNumLaggingEvents()

getRTEvaluation

public double getRTEvaluation()
Returns the percentage where events are processed in real time (within tolerance specified by setRTTolerance() (not implemented).

setRTTolerance

public void setRTTolerance(long v_)

getRTTolerance

public long getRTTolerance()

getQ

public Queue getQ()

getEventQueue

public java.lang.Object getEventQueue()
Overrides:
getEventQueue in class ACARuntime

threadBecomesWaiting

protected void threadBecomesWaiting(AWorkerThread exe_)

threadRequestsSleeping

protected boolean threadRequestsSleeping(AWorkerThread exe_,
                                         double time_)
Subclasses should override this method to handle the event when a workerthread requests to become waiting.
Returns:
false if current thread should continue execution (the request is rejected).

systemBecomesIdle

protected void systemBecomesIdle(AWorkerThread exe_)
Subclasses should override this method to handle the event when all workerthreads in the system become either waiting or idle.
Parameters:
exe_ - current thread, requesting waiting and causing the system to become idle if the request is granted.

systemBecomesInactive

protected void systemBecomesInactive()
Called when system becomes inactive, that is, no thread is active or all threads are waiting. In most cases, subclasses do not need to override this method.

wakeupThreadInfo

public java.lang.String wakeupThreadInfo()

triggerWakeupThread

protected void triggerWakeupThread()

off

protected void off(ACATimer handle_)
Cancels a fork event.
Overrides:
off in class ACARuntime

DRCL JavaSim API

Copyright © 2001 - DRCL, OSU     ~ Back to JavaSim Home ~