aa.core
Class SchedulerManager

java.lang.Object
  extended byjava.lang.Thread
      extended byaa.core.SchedulerManager
All Implemented Interfaces:
java.lang.Runnable

public class SchedulerManager
extends java.lang.Thread

This class is the actor scheduler, and it schedules all actors on this platform

Author:
xinghuizhao

Field Summary
private  boolean m_bGranularity
           
private  CyberOrgManager m_comCyberOrgManager
           
private  java.util.Hashtable m_htThreadTimeslice
           
private  long m_lLargestSlice
           
private  java.lang.Long m_longBeginSign
           
private  long m_lSmallestSlice
           
private  Queue m_queueThreads
           
private  java.lang.Thread m_threadCurrent
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SchedulerManager(CyberOrgManager p_comCyberOrgManager)
          Creates a new instance of SchedulerManager
SchedulerManager(long p_lSmallestSlice, long p_lLargestSlice)
           
 
Method Summary
 long getTimeSlice(java.lang.Thread p_thread)
          Look up the hashtable to find out the time slice of specific actor
 void insert(java.lang.Thread p_thread)
          Called by CyberOrgManager when a cyberorg is reactived.
 void insert(java.lang.Thread p_thread, long p_lTimeslice)
          This method inserts a thread into the thread queue for thread scheduling.
private  java.lang.Thread remove()
          Remove a thread from the thread queue for scheduling.
 void remove(java.lang.Thread p_thread)
          Remove specific thread
This method is called when migration happens in order to remove the migrating actors from the local scheduler
 void resAlloc(java.lang.Thread p_thread, long p_lTimeSlice)
          Reallocates resource for specific thread
 void run()
          The main loop
 void scaleup(long p_lFactor)
          In granularity control, this method is called to enlarge the time slices for each actor using a specific factor
protected  void uninit()
          Uninitializes this program.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_htThreadTimeslice

private java.util.Hashtable m_htThreadTimeslice

m_queueThreads

private Queue m_queueThreads

m_threadCurrent

private java.lang.Thread m_threadCurrent

m_lSmallestSlice

private long m_lSmallestSlice

m_lLargestSlice

private long m_lLargestSlice

m_bGranularity

private boolean m_bGranularity

m_comCyberOrgManager

private CyberOrgManager m_comCyberOrgManager

m_longBeginSign

private java.lang.Long m_longBeginSign
Constructor Detail

SchedulerManager

public SchedulerManager(CyberOrgManager p_comCyberOrgManager)
Creates a new instance of SchedulerManager


SchedulerManager

public SchedulerManager(long p_lSmallestSlice,
                        long p_lLargestSlice)
Method Detail

uninit

protected void uninit()
Uninitializes this program. This method is called by the Platform.


remove

private java.lang.Thread remove()
Remove a thread from the thread queue for scheduling. return the first thread of thread queue

Returns:
The first thread of thread queue

remove

public void remove(java.lang.Thread p_thread)
Remove specific thread
This method is called when migration happens in order to remove the migrating actors from the local scheduler

Parameters:
p_thread - The thread being removed

insert

public void insert(java.lang.Thread p_thread,
                   long p_lTimeslice)
This method inserts a thread into the thread queue for thread scheduling.
p_thread: the reference to a thread to be inserted to the thread queue
p_lTimeslice: timeslice in milliseconds that the corresponding thread is assigned in one scheduling cycle

Parameters:
p_thread - The reference to a thread to be inserted to the thread queue
p_lTimeslice - Timeslice in milliseconds that the corresponding thread is assigned in one scheduling cycle

insert

public void insert(java.lang.Thread p_thread)
Called by CyberOrgManager when a cyberorg is reactived.

Parameters:
p_thread - The thread being inserted

getTimeSlice

public long getTimeSlice(java.lang.Thread p_thread)
Look up the hashtable to find out the time slice of specific actor

Parameters:
p_thread - The reference to a thread
Returns:
The corresponding time slice allocated the the given thread

resAlloc

public void resAlloc(java.lang.Thread p_thread,
                     long p_lTimeSlice)
Reallocates resource for specific thread

Parameters:
p_thread - The thread
p_lTimeSlice - The time slice being allocated to the given thread

scaleup

public void scaleup(long p_lFactor)
In granularity control, this method is called to enlarge the time slices for each actor using a specific factor

Parameters:
p_lFactor - The factor used to scale up the granularity control

run

public void run()
The main loop