osl.scheduler.basic
Class BasicScheduler

java.lang.Object
  |
  +--osl.scheduler.basic.BasicScheduler

public class BasicScheduler
extends java.lang.Object
implements Scheduler, java.lang.Runnable

This class implements a simple scheduler for use with foundry nodes. The default behavior defined in this class is to schedule all foundry threads in a round-robin fashion. This is to ensure fairness which, unfortunately, is not required by the default Java thread scheduling mechanism.

A new scheduler is started by calling the schedule method defined below. In order for scheduling to be effective, it is important that the main scheduling thread is never blocked indefinitely. This can be guaranteed by making the main scheduling thread the highest priority thread in the Java virtual machine. If this priority is mPri, then each thread managed by the scheduler has an initial priority of mPri - 2. When scheduling a thread, the scheduler promotes a threads priority to mPri -1 and sleeps for TIME_SLICE milliseconds. Upon re-awakening the pre-empted thread's priority is demoted, and a new thread is selected for execution.

Version:
$Revision: 1.7 $ ($Date: 1998/10/05 15:47:41 $)
See Also:
Scheduler

Constructor Summary
BasicScheduler()
           
 
Method Summary
 void run()
          This is just provided for convenience.
 void schedulerInitialize()
          The initialization function for the scheduler.
 void schedulerInitialize(java.lang.String T)
          The initialization function for the scheduler.
 void scheduleThread(java.lang.Thread toSched)
          This method is used to submit a thread to be scheduled by the thread scheduler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicScheduler

public BasicScheduler()
Method Detail

schedulerInitialize

public void schedulerInitialize()
The initialization function for the scheduler. This is called immediately after the scheduler is created but before it is started.
Specified by:
schedulerInitialize in interface Scheduler

schedulerInitialize

public void schedulerInitialize(java.lang.String T)
The initialization function for the scheduler. This is called immediately after the scheduler is created but before it is started.
Parameters:
T - Time slice for each thread (default = 3).

scheduleThread

public void scheduleThread(java.lang.Thread toSched)
                    throws java.lang.IllegalThreadStateException
This method is used to submit a thread to be scheduled by the thread scheduler. The new thread MUST NOT be running yet. The thread scheduler calls start when it adds the thread to its schedule. An exception is raised if the thread has already been started.
Specified by:
scheduleThread in interface Scheduler

run

public void run()
This is just provided for convenience.
Specified by:
run in interface java.lang.Runnable