Boeing Simulation 3.1 API Specification

util
Class AdaptiveThreadManager

java.lang.Object
  |
  +--util.AdaptiveThreadManager

public class AdaptiveThreadManager
extends Object

A AdaptiveThreadManager controls a pool of AdaptivePeriodicThread objects and automatically adjusts the period of the threads until the threads are feasible in the system. If it is not possible to have all the threads running at one time, running precidence is based on registration order. If threads are waiting on system resources, when a thread finishes, systems resources will be distributed based on registration order to the threads waiting.

Version:
$Revision: 1.2 $
Author:
Dave Jurgens
See Also:
AdaptivePeriodicThread

Field Summary
private  Set activeThreads
          The set of threads that are currently running.
private static boolean debug
          Flag for turning debug output off and on
private static double PERIOD_ADJUST_PERC
          The percentage of the difference between the current period and maximum period of a thread that reallocateResources(AdaptivePeriodicThread) will try to increase if resources are required.
private static util.AdaptiveThreadManager singleton
          The singleton instance of this class.
private  LinkedList waitingThreads
          The set of threads waiting for system resources.
 
Constructor Summary
private AdaptiveThreadManager()
           
 
Method Summary
private  void debug(String s)
          Emits a debug message if debug is enabled.
static util.AdaptiveThreadManager instance()
           
private  boolean reallocateResources(util.AdaptivePeriodicThread thread)
          Adjusts the period of the new thread or, if necessary, the periods of currently active threads to free resources for the new thread, and returns whether the thread is feasible after the adjustments, if any, were made.
(package private)  void registerShutdown(util.AdaptivePeriodicThread thread)
           
(package private)  void registerThread(util.AdaptivePeriodicThread thread)
          Starts this thread immediately if either the resources for feasible execution are immediately available, or current resources can be adjusted to allow for this threads execution.
private  void startReallocationThread()
          Attempts to redistribute resources to waiting threads when a currently running thread finishes its execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

private static util.AdaptiveThreadManager singleton
The singleton instance of this class.


waitingThreads

private final LinkedList waitingThreads
The set of threads waiting for system resources.


PERIOD_ADJUST_PERC

private static final double PERIOD_ADJUST_PERC
The percentage of the difference between the current period and maximum period of a thread that reallocateResources(AdaptivePeriodicThread) will try to increase if resources are required.

See Also:
Constant Field Values

activeThreads

private final Set activeThreads
The set of threads that are currently running.


debug

private static final boolean debug
Flag for turning debug output off and on

See Also:
Constant Field Values
Constructor Detail

AdaptiveThreadManager

private AdaptiveThreadManager()
Method Detail

instance

public static util.AdaptiveThreadManager instance()

debug

private void debug(String s)
Emits a debug message if debug is enabled.


reallocateResources

private boolean reallocateResources(util.AdaptivePeriodicThread thread)
Adjusts the period of the new thread or, if necessary, the periods of currently active threads to free resources for the new thread, and returns whether the thread is feasible after the adjustments, if any, were made. If the thread is still not feasible after adjustments were made, the adjusted threads will have their periods reset to the prior value. The currently running threads will never have their periods set larger than the value specified by AdaptivePeriodicThread.getMaximumPeriod().


registerThread

void registerThread(util.AdaptivePeriodicThread thread)
Starts this thread immediately if either the resources for feasible execution are immediately available, or current resources can be adjusted to allow for this threads execution. If no resources can be found, this method will block until resources can be acquired.


registerShutdown

void registerShutdown(util.AdaptivePeriodicThread thread)

startReallocationThread

private void startReallocationThread()
Attempts to redistribute resources to waiting threads when a currently running thread finishes its execution.

See Also:
registerShutdown(AdaptivePeriodicThread)

Boeing Simulation 3.1 API Specification

To submit a bug or feature email the author of that class. Funding for this research was provided by Boeing and DARPA.