joeq.Scheduler
Class jq_NativeThread

java.lang.Object
  extended by joeq.Scheduler.jq_NativeThread
All Implemented Interfaces:
jq_DontAlign

public class jq_NativeThread
extends Object
implements jq_DontAlign

A jq_NativeThread corresponds to a virtual CPU in the scheduler. There is one jq_NativeThread object for each underlying (heavyweight) kernel thread. The Java (lightweight) threads are multiplexed across the jq_NativeThreads.

Version:
$Id: jq_NativeThread.java,v 1.61 2004/09/30 03:35:30 joewhaley Exp $
Author:
John Whaley , Miho Kurano

Field Summary
static jq_Class _class
           
static jq_StaticMethod _ctrl_break_handler
           
static jq_InstanceMethod _nativeThreadEntry
           
static jq_StaticField _num_of_daemon_threads
           
static jq_StaticField _num_of_java_threads
           
static jq_InstanceMethod _schedulerLoop
           
static jq_InstanceMethod _threadSwitch
           
static boolean CHECK
           
 boolean DETERMINISTIC
           
static int[] DISTRIBUTION
           
static jq_NativeThread initial_native_thread
          Data structure to represent the native thread that exists at virtual machine startup.
 jq_InterrupterThread it
           
static int MAX_NATIVE_THREADS
           
static jq_NativeThread[] native_threads
          An array of all native threads.
static int NUM_OF_QUEUES
           
static int relatively_prime_value
          GCD of relatively_prime_value and the maximum value in DISTRIBUTION should be 1.
static boolean STATISTICS
           
static boolean TRACE
          Trace flag.
static float TRANSFER_THRESHOLD
           
static boolean USE_INTERRUPTER_THREAD
           
 
Method Summary
static boolean allNativeThreadsInitialized()
          Returns true iff all native threads are initialized.
static void ctrl_break_handler()
           
 void dump(jq_RegisterState regs)
           
static void dumpAllThreads()
           
static void dumpStatistics()
           
 void dumpStats()
           
static void endCurrentJavaThread()
          End the currently-executing Java thread and go back to the scheduler loop to pick up another thread.
 CodeAllocator getCodeAllocator()
          Get the native thread-local code allocator.
 boolean getContext(jq_RegisterState r)
          Gets context of this native thread and puts it in r.
 jq_Thread getCurrentJavaThread()
          Get the currently-executing Java thread.
 jq_Thread getCurrentThread()
          Returns the jq_Thread that is currently running on this native thread.
 HeapAllocator getHeapAllocator()
          Get the native thread-local heap allocator.
 jq_ThreadQueue getIdleQueue()
           
 int getIndex()
           
 jq_ThreadQueue getReadyQueue(int i)
           
 jq_ThreadQueue getTransferQueue()
           
static void initBreakThread()
           
static void initInitialNativeThread()
          Initialize the initial native thread.
static void initNativeThreads(jq_NativeThread nt, int num)
          Initialize the extra native threads.
 void nativeThreadEntry()
          The entry point for new native threads.
 void resume()
          Starts up/resumes this native thread.
static void resumeAllThreads()
           
 void schedulerLoop()
           
 boolean setContext(jq_RegisterState r)
          Sets context of this native thread to r.
static void startJavaThread(jq_Thread t)
          Put the given Java thread on the queue of the least-busy native thread.
static void startNativeThreads()
          Start up the extra native threads.
 void suspend()
          Suspends this native thread.
static void suspendAllThreads()
           
 void threadSwitch()
          Thread switch based on a timer or poker interrupt.
 String toString()
           
 void yieldCurrentThread()
          Thread switch based on explicit yield.
 void yieldCurrentThreadTo(jq_Thread t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRACE

public static boolean TRACE
Trace flag. When this is true, prints out debugging information about what is going on in the scheduler.


CHECK

public static boolean CHECK

STATISTICS

public static final boolean STATISTICS
See Also:
Constant Field Values

initial_native_thread

public static final jq_NativeThread initial_native_thread
Data structure to represent the native thread that exists at virtual machine startup.


native_threads

public static jq_NativeThread[] native_threads
An array of all native threads.


MAX_NATIVE_THREADS

public static final int MAX_NATIVE_THREADS
See Also:
Constant Field Values

NUM_OF_QUEUES

public static final int NUM_OF_QUEUES
See Also:
Constant Field Values

USE_INTERRUPTER_THREAD

public static boolean USE_INTERRUPTER_THREAD

it

public jq_InterrupterThread it

TRANSFER_THRESHOLD

public static float TRANSFER_THRESHOLD

DETERMINISTIC

public boolean DETERMINISTIC

relatively_prime_value

public static final int relatively_prime_value
GCD of relatively_prime_value and the maximum value in DISTRIBUTION should be 1.

See Also:
Constant Field Values

DISTRIBUTION

public static final int[] DISTRIBUTION

_class

public static final jq_Class _class

_nativeThreadEntry

public static final jq_InstanceMethod _nativeThreadEntry

_schedulerLoop

public static final jq_InstanceMethod _schedulerLoop

_threadSwitch

public static final jq_InstanceMethod _threadSwitch

_ctrl_break_handler

public static final jq_StaticMethod _ctrl_break_handler

_num_of_java_threads

public static final jq_StaticField _num_of_java_threads

_num_of_daemon_threads

public static final jq_StaticField _num_of_daemon_threads
Method Detail

initInitialNativeThread

public static void initInitialNativeThread()
Initialize the initial native thread. Must be the first thing called at virtual machine startup.


initNativeThreads

public static void initNativeThreads(jq_NativeThread nt,
                                     int num)
Initialize the extra native threads.

Parameters:
nt - initial native thread
num - number of native threads to initialize

startNativeThreads

public static void startNativeThreads()
Start up the extra native threads.


allNativeThreadsInitialized

public static boolean allNativeThreadsInitialized()
Returns true iff all native threads are initialized.


getCurrentThread

public jq_Thread getCurrentThread()
Returns the jq_Thread that is currently running on this native thread.


getCodeAllocator

public CodeAllocator getCodeAllocator()
Get the native thread-local code allocator.


getHeapAllocator

public HeapAllocator getHeapAllocator()
Get the native thread-local heap allocator.


getCurrentJavaThread

public jq_Thread getCurrentJavaThread()
Get the currently-executing Java thread.


resume

public void resume()
Starts up/resumes this native thread.


suspend

public void suspend()
Suspends this native thread.


getContext

public boolean getContext(jq_RegisterState r)
Gets context of this native thread and puts it in r.


setContext

public boolean setContext(jq_RegisterState r)
Sets context of this native thread to r.


startJavaThread

public static void startJavaThread(jq_Thread t)
Put the given Java thread on the queue of the least-busy native thread.


endCurrentJavaThread

public static void endCurrentJavaThread()
End the currently-executing Java thread and go back to the scheduler loop to pick up another thread.


nativeThreadEntry

public void nativeThreadEntry()
The entry point for new native threads.


schedulerLoop

public void schedulerLoop()

dumpStatistics

public static void dumpStatistics()

dumpStats

public void dumpStats()

threadSwitch

public void threadSwitch()
Thread switch based on a timer or poker interrupt.


yieldCurrentThread

public void yieldCurrentThread()
Thread switch based on explicit yield.


yieldCurrentThreadTo

public void yieldCurrentThreadTo(jq_Thread t)

toString

public String toString()
Overrides:
toString in class Object

getIndex

public int getIndex()

ctrl_break_handler

public static void ctrl_break_handler()

dumpAllThreads

public static void dumpAllThreads()

initBreakThread

public static void initBreakThread()

suspendAllThreads

public static void suspendAllThreads()

resumeAllThreads

public static void resumeAllThreads()

dump

public void dump(jq_RegisterState regs)

getReadyQueue

public jq_ThreadQueue getReadyQueue(int i)

getIdleQueue

public jq_ThreadQueue getIdleQueue()

getTransferQueue

public jq_ThreadQueue getTransferQueue()


Copyright © 2001-2005 John Whaley. All Rights Reserved.