Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

thread.h File Reference


Detailed Description

Definition of the java.lang.Thread structure in this real machine implementation.

There is no notion of a thread group natively in this JVM. Thread groups are supported at the class library level.

Control

$URL: https://svn.apache.org/path/name/thread.h $ $Id: thread.h 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file thread.h.

#include <setjmp.h>
#include "jvmreg.h"

Go to the source code of this file.

Data Structures

struct  rthread
 Real machine thread model implementation. More...

Macros for addressing threads

Parameters:
thridx Thread table index into the global rjvm.thread[] array (via pjvm->thread[]).


#define CURRENT_THREAD   pjvm->current_thread
 Access structures of the thread now running in the JVM.
#define CURRENT_THREAD_ACTIVATE_THIS_STATE(state)   threadstate_activate_##state(CURRENT_THREAD)
 Activate current thread state, actually moving it from a prior state into a requested state, see threadstate_activate_XXX() for specifics.
#define CURRENT_THREAD_PROCESS_THIS_STATE(state)   threadstate_process_##state(CURRENT_THREAD)
 Process activities for current thread in its current state, see threadstate_process_XXX() for specifics.
#define CURRENT_THREAD_REQUEST_NEXT_STATE(state)   REQ_NEXT_STATE(state, CURRENT_THREAD)
 Request that the current thread move into a certain thread state, see threadstate_request_XXX() for specifics.
#define NEXT_STATE(thridx)   THREAD(thridx).next_state
 Next requested thread state.
#define PREV_STATE(thridx)   THREAD(thridx).prev_state
 Previous actual thread state.
#define REQ_NEXT_STATE(state, thridx)   threadstate_request_##state(thridx)
 Place a thread into requested thread state, see threadstate_request_XXX() for specifics.
#define THIS_STATE(thridx)   THREAD(thridx).this_state
 This current thread state.
#define THREAD(thridx)   pjvm->thread[thridx]
 Access structures of thread table at certain index.
#define THREAD_ACTIVATE_THIS_STATE(state, thridx)   threadstate_activate_##state(thridx)
 Activate arbitrary thread state, actually moving it from a prior state into a requested state, see threadstate_activate_XXX() for specifics.
#define THREAD_PROCESS_THIS_STATE(state, thridx)   threadstate_process_##state(thridx)
 Process activities for an arbitrary thread in its current state, see threadstate_process_XXX() for specifics.
#define THREAD_REQUEST_NEXT_STATE(state, thridx)   REQ_NEXT_STATE(state, thridx)
 Request that an arbitrary thread move into a certain thread state, see threadstate_request_XXX() for specifics.

Thread state name strings

#define THREAD_STATE_ACQUIRE_DESC   "acquire"
#define THREAD_STATE_BADLOGIC_DESC   "bad_logic"
#define THREAD_STATE_BLOCKED_DESC   "blocked"
#define THREAD_STATE_BLOCKINGEVENT_DESC   "blockingevent"
#define THREAD_STATE_COMPLETE_DESC   "complete"
#define THREAD_STATE_DEAD_DESC   "dead"
#define THREAD_STATE_ILLEGAL_DESC   "illegal"
#define THREAD_STATE_LOCK_DESC   "lock"
#define THREAD_STATE_NEW_DESC   "new"
#define THREAD_STATE_NOTIFY_DESC   "notify"
#define THREAD_STATE_RELEASE_DESC   "release"
#define THREAD_STATE_RUNNABLE_DESC   "runnable"
#define THREAD_STATE_RUNNING_DESC   "running"
#define THREAD_STATE_START_DESC   "started"
#define THREAD_STATE_SYNCHRONIZED_DESC   "synchronized"
#define THREAD_STATE_UNBLOCKED_DESC   "unblocked"
#define THREAD_STATE_WAIT_DESC   "wait"
const rcharthread_state_name

Thread state machine state definitions.

Thread state machine state names, including min and max states.

#define THREAD_STATE_MAX_STATE   THREAD_STATE_BADLOGIC
 Highest possible state number.
#define THREAD_STATE_MIN_STATE   THREAD_STATE_NEW
 Lowest possible state number.
enum  thread_state_enum {
  THREAD_STATE_NEW = 0, THREAD_STATE_START = 1, THREAD_STATE_RUNNABLE = 2, THREAD_STATE_RUNNING = 3,
  THREAD_STATE_COMPLETE = 4, THREAD_STATE_BLOCKINGEVENT = 5, THREAD_STATE_BLOCKED = 6, THREAD_STATE_UNBLOCKED = 7,
  THREAD_STATE_SYNCHRONIZED = 8, THREAD_STATE_RELEASE = 9, THREAD_STATE_WAIT = 10, THREAD_STATE_NOTIFY = 11,
  THREAD_STATE_LOCK = 12, THREAD_STATE_ACQUIRE = 13, THREAD_STATE_DEAD = 14, THREAD_STATE_BADLOGIC = 15
}

JVM state priority definitions.

enum  thread_priority_enum { THREAD_PRIORITY_BAD = 0, THREAD_PRIORITY_MIN = 1, THREAD_PRIORITY_NORM = 5, THREAD_PRIORITY_MAX = 10 }

Thread state phases.

Each thread state has three phases, each of which is handled by a dedicated function.

Requesting a state checks to see if a transition from the current state into the requested state is valid. If so, the NEXT state is set to the requested one. If not, the request is ignored.

Activating a state moves the thread into the requested NEXT state so its THIS state changes. Its PREV state then reports the former state.

Processing a state performs the activities for that state.

Parameters:
thridx Thread table index of thread to process.
Returns:
rtrue if activities transpired normally, otherwise rfalse.


rboolean threadstate_activate_acquire (jvm_thread_index thridx)
 Activate the ACQUIRE thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_badlogic (jvm_thread_index thridx)
 Activate the BADLOGIC thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_blocked (jvm_thread_index thridx)
 Activate the BLOCKED thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_blockingevent (jvm_thread_index thridx)
 Activate the BLOCKINGEVENT thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_complete (jvm_thread_index thridx)
 Activate the COMPLETE thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_dead (jvm_thread_index thridx)
 Activate the DEAD thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_lock (jvm_thread_index thridx)
 Activate the LOCK thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_new (jvm_thread_index thridx)
 Activate the NEW thread state for a new thread.
rboolean threadstate_activate_notify (jvm_thread_index thridx)
 Activate the NOTIFY thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_release (jvm_thread_index thridx)
 Activate the RELEASE thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_runnable (jvm_thread_index thridx)
 Activate the RUNNABLE thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_running (jvm_thread_index thridx)
 Activate the RUNNING thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_start (jvm_thread_index thridx)
 Activate the START thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_synchronized (jvm_thread_index thridx)
 Activate the SYNCHRONIZED thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_unblocked (jvm_thread_index thridx)
 Activate the UNBLOCKED thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_activate_wait (jvm_thread_index thridx)
 Activate the WAIT thread state of a thread known to be coming from a valid previous state.
rboolean threadstate_process_acquire (jvm_thread_index thridx)
 Process the ACQUIRE thread state.
rboolean threadstate_process_badlogic (jvm_thread_index thridx)
 Process the BADLOGIC thread state.
rboolean threadstate_process_blocked (jvm_thread_index thridx)
 Process the BLOCKED thread state.
rboolean threadstate_process_blockingevent (jvm_thread_index thridx)
 Process the BLOCKINGEVENT thread state.
rboolean threadstate_process_complete (jvm_thread_index thridx)
 Process the COMPLETE thread state.
rboolean threadstate_process_dead (jvm_thread_index thridx)
 Process the DEAD thread state.
rboolean threadstate_process_lock (jvm_thread_index thridx)
 Process the LOCK thread state.
rboolean threadstate_process_new (jvm_thread_index thridx)
 Process the NEW thread state.
rboolean threadstate_process_notify (jvm_thread_index thridx)
 Process the NOTIFY thread state.
rboolean threadstate_process_release (jvm_thread_index thridx)
 Process the RELEASE thread state.
rboolean threadstate_process_runnable (jvm_thread_index thridx)
 Process the RUNNABLE thread state.
rboolean threadstate_process_running (jvm_thread_index thridx)
 Process the RUNNING thread state.
rboolean threadstate_process_start (jvm_thread_index thridx)
 Process the START thread state.
rboolean threadstate_process_synchronized (jvm_thread_index thridx)
 Process the SYNCHRONIZED thread state.
rboolean threadstate_process_unblocked (jvm_thread_index thridx)
 Process the UNBLOCKED thread state.
rboolean threadstate_process_wait (jvm_thread_index thridx)
 Process the WAIT thread state.
rboolean threadstate_request_acquire (jvm_thread_index thridx)
 Request the ACQUIRE state.
rboolean threadstate_request_badlogic (jvm_thread_index thridx)
 Request the BADLOGIC state.
rboolean threadstate_request_blocked (jvm_thread_index thridx)
 Request the BLOCKED state.
rboolean threadstate_request_blockingevent (jvm_thread_index thridx)
 Request the BLOCKINGEVENT state.
rboolean threadstate_request_complete (jvm_thread_index thridx)
 Request the COMPLETE state.
rboolean threadstate_request_dead (jvm_thread_index thridx)
 Request the DEAD state.
rboolean threadstate_request_lock (jvm_thread_index thridx)
 Request the LOCK state.
rboolean threadstate_request_new (jvm_thread_index thridx)
 Request the NEW thread state.
rboolean threadstate_request_notify (jvm_thread_index thridx)
 Request the NOTIFY state.
rboolean threadstate_request_release (jvm_thread_index thridx)
 Request the RELEASE state.
rboolean threadstate_request_runnable (jvm_thread_index thridx)
 Request the RUNNABLE state.
rboolean threadstate_request_running (jvm_thread_index thridx)
 Request the RUNNING state.
rboolean threadstate_request_start (jvm_thread_index thridx)
 Request the START state.
rboolean threadstate_request_synchronized (jvm_thread_index thridx)
 Request the SYNCHRONIZED state.
rboolean threadstate_request_unblocked (jvm_thread_index thridx)
 Request the UNBLOCKED state.
rboolean threadstate_request_wait (jvm_thread_index thridx)
 Request the WAIT state.

Defines

#define THREAD_NAME_MAX_LEN   64
 Arbitrary max thread name length.
#define THREAD_STATUS_EMPTY   0x0000
 This slot is available for use.
#define THREAD_STATUS_INTERRUPTED   0x0800
 thread has been interrupted
#define THREAD_STATUS_INTERRUPTIBLEIO   0x0200
 thread is waiting on an interruptable I/O channel in class java.nio.channels.InterruptibleChannel
#define THREAD_STATUS_INUSE   0x0001
 This slot contains a thread.
#define THREAD_STATUS_ISDAEMON   0x0004
 Daemon thread state, vs user thread, per Thread.isdaemon().
#define THREAD_STATUS_JOIN4EVER   0x0010
 thread has unconditionally joined another
#define THREAD_STATUS_JOINTIMED   0x0020
 thread has joined another, but is waiting for a finite time
#define THREAD_STATUS_NOTIFIED   0x0400
 thread has been notified
#define THREAD_STATUS_NULL   0x0002
 Null thread (only 1 exists in normal use, any else besides the JVMCFG_NULL_THREAD is a thread slot that is being initialized.
#define THREAD_STATUS_SLEEP   0x0008
 thread is sleeping
#define THREAD_STATUS_SUSPEND   0x0100
 thread is suspended, can be resumed
#define THREAD_STATUS_THREW_ERROR   0x2000
 thread threw a java.lang.Error (but NOT a java.lang.Exception).
#define THREAD_STATUS_THREW_EXCEPTION   0x1000
 thread threw a java.lang.Exception (but NOT a java.lang.Error).
#define THREAD_STATUS_THREW_THROWABLE   0x4000
 thread threw a java.lang.Throwable of unknowable type.
#define THREAD_STATUS_THREW_UNCAUGHT   0x8000
 A java.lang.Throwable of some type was thrown, but not handled by the Java code itself.
#define THREAD_STATUS_WAIT4EVER   0x0040
 thread is unconditionally waiting
#define THREAD_STATUS_WAITTIMED   0x0080
 thread is waiting, but finite time

Functions

 ARCH_COPYRIGHT_APACHE (thread, h,"$URL: https://svn.apache.org/path/name/thread.h $ $Id: thread.h 0 09/28/2005 dlydick $")
jvm_thread_index thread_class_load (rchar *clsname, rchar *mthname, rchar *mthdesc, rint priority, rboolean isdaemon, rboolean usesystemthread, rboolean find_registerNatives)
 Load a class onto a thread during JVM initialization.
rboolean thread_die (jvm_thread_index thridx)
 Terminate and deallocate a thread that is currently in the DEAD state.
int thread_exception_setup (jvm_thread_index thridx)
 Set up JVM thread-relative exception handler-- implements setjmp(3)/longjmp(3).
rvoid thread_init (rvoid)
rvoid thread_shutdown (rvoid)
const rcharthread_state_get_name (rushort state)
 Map state numbers to state names.
rvoid thread_throw_exception (jvm_thread_index thridx, rushort thread_status_bits, rchar *exception_name)
 Global handler setup for JVM thread errors and exceptions-- implements setjmp(3).
rboolean threadutil_holds_lock (jvm_thread_index thridx, jvm_object_hash objhashlock)
 Examine an object to see if a thread owns its monitor lock.
rvoid threadutil_update_blockingevents (jvm_thread_index thridxcurr)
 Complete the UNtimed Thread.join() request and allow threads that have joined this one to resume execution.
rvoid threadutil_update_lock (jvm_thread_index thridxcurr)
rvoid threadutil_update_sleeptime_interval (rvoid)
 Update the interval timer for this thread from java.lang.Thread.sleep() or from a timed java.lang.Thread.wait() or java.lang.Thread.join().
rvoid threadutil_update_wait (jvm_thread_index thridxcurr)


Define Documentation

#define THREAD thridx   )     pjvm->thread[thridx]
 

Access structures of thread table at certain index.

The thread table, being an array of slots, provides space for one thread instance per slot. This macro references one of them using the thridx index.

Returns:
pointer to a thread slot

Definition at line 75 of file thread.h.

Referenced by jlObject_wait4ever(), jlThread_checkAccess(), jlThread_countStackFrames(), jlThread_destroy(), jlThread_interrupt(), jlThread_isAlive(), jlThread_isDaemon(), jlThread_jointimed_nanos(), jlThread_setDaemon(), jlThread_sleep(), jlThread_start(), jlThread_yield(), jvmutil_print_errtype_stack(), object_run_method(), objectutil_synchronize(), opcode_run(), thread_init(), thread_new_common(), thread_shutdown(), thread_state_get_name(), threadstate_process_blockingevent(), threadutil_update_sleeptime_interval(), threadutil_update_wait(), and timeslice_get_thread_sleeptime().

#define CURRENT_THREAD   pjvm->current_thread
 

Access structures of the thread now running in the JVM.

Definition at line 77 of file thread.h.

Referenced by exit_throw_exception(), jlObject_wait4ever(), jlThread_currentThread(), jlThread_getPriority(), jlThread_interrupted(), jlThread_isDaemon(), jlThread_jointimed_nanos(), jlThread_setDaemon(), jlThread_setPriority(), jlThread_sleep(), jlThread_start(), jlThread_yield(), objectutil_synchronize(), opcode_run(), and thread_init().

#define PREV_STATE thridx   )     THREAD(thridx).prev_state
 

Previous actual thread state.

Definition at line 82 of file thread.h.

Referenced by jvm_run().

#define THIS_STATE thridx   )     THREAD(thridx).this_state
 

This current thread state.

Definition at line 87 of file thread.h.

Referenced by jvm_run(), threadstate_activate_start(), threadstate_activate_unblocked(), threadstate_process_blocked(), threadstate_process_running(), threadstate_request_release(), threadstate_request_runnable(), and threadstate_request_running().

#define NEXT_STATE thridx   )     THREAD(thridx).next_state
 

Next requested thread state.

Definition at line 92 of file thread.h.

Referenced by jvm_run().

#define REQ_NEXT_STATE state,
thridx   )     threadstate_request_##state(thridx)
 

Place a thread into requested thread state, see threadstate_request_XXX() for specifics.

Definition at line 97 of file thread.h.

#define CURRENT_THREAD_REQUEST_NEXT_STATE state   )     REQ_NEXT_STATE(state, CURRENT_THREAD)
 

Request that the current thread move into a certain thread state, see threadstate_request_XXX() for specifics.

Definition at line 107 of file thread.h.

Referenced by jvm_run().

#define THREAD_REQUEST_NEXT_STATE state,
thridx   )     REQ_NEXT_STATE(state, thridx)
 

Request that an arbitrary thread move into a certain thread state, see threadstate_request_XXX() for specifics.

Definition at line 118 of file thread.h.

Referenced by opcode_run().

#define CURRENT_THREAD_ACTIVATE_THIS_STATE state   )     threadstate_activate_##state(CURRENT_THREAD)
 

Activate current thread state, actually moving it from a prior state into a requested state, see threadstate_activate_XXX() for specifics.

Definition at line 130 of file thread.h.

#define THREAD_ACTIVATE_THIS_STATE state,
thridx   )     threadstate_activate_##state(thridx)
 

Activate arbitrary thread state, actually moving it from a prior state into a requested state, see threadstate_activate_XXX() for specifics.

Definition at line 143 of file thread.h.

#define CURRENT_THREAD_PROCESS_THIS_STATE state   )     threadstate_process_##state(CURRENT_THREAD)
 

Process activities for current thread in its current state, see threadstate_process_XXX() for specifics.

Definition at line 156 of file thread.h.

#define THREAD_PROCESS_THIS_STATE state,
thridx   )     threadstate_process_##state(thridx)
 

Process activities for an arbitrary thread in its current state, see threadstate_process_XXX() for specifics.

Definition at line 168 of file thread.h.

#define THREAD_STATE_MIN_STATE   THREAD_STATE_NEW
 

Lowest possible state number.

Definition at line 244 of file thread.h.

#define THREAD_STATE_MAX_STATE   THREAD_STATE_BADLOGIC
 

Highest possible state number.

Definition at line 246 of file thread.h.

#define THREAD_NAME_MAX_LEN   64
 

Arbitrary max thread name length.

Definition at line 283 of file thread.h.

Referenced by thread_init().

#define THREAD_STATUS_EMPTY   0x0000
 

This slot is available for use.

DO NOT CHANGE since this is also the normal setjmp(3) return code from thread_exception_setup()

Definition at line 293 of file thread.h.

Referenced by opcode_load_run_throwable(), opcode_run(), and thread_init().

#define THREAD_STATUS_INUSE   0x0001
 

This slot contains a thread.

Definition at line 301 of file thread.h.

Referenced by thread_init(), thread_state_get_name(), and threadutil_update_sleeptime_interval().

#define THREAD_STATUS_NULL   0x0002
 

Null thread (only 1 exists in normal use, any else besides the JVMCFG_NULL_THREAD is a thread slot that is being initialized.

)

Definition at line 302 of file thread.h.

Referenced by thread_init().

#define THREAD_STATUS_ISDAEMON   0x0004
 

Daemon thread state, vs user thread, per Thread.isdaemon().

Definition at line 309 of file thread.h.

Referenced by jlThread_destroy().

#define THREAD_STATUS_SLEEP   0x0008
 

thread is sleeping

Definition at line 312 of file thread.h.

Referenced by jlThread_sleep(), and threadutil_update_sleeptime_interval().

#define THREAD_STATUS_JOIN4EVER   0x0010
 

thread has unconditionally joined another

Definition at line 314 of file thread.h.

Referenced by threadstate_process_blockingevent().

#define THREAD_STATUS_JOINTIMED   0x0020
 

thread has joined another, but is waiting for a finite time

Definition at line 317 of file thread.h.

Referenced by threadstate_process_blockingevent(), and threadutil_update_sleeptime_interval().

#define THREAD_STATUS_WAIT4EVER   0x0040
 

thread is unconditionally waiting

Definition at line 320 of file thread.h.

Referenced by jlObject_wait4ever().

#define THREAD_STATUS_WAITTIMED   0x0080
 

thread is waiting, but finite time

Definition at line 323 of file thread.h.

Referenced by threadutil_update_sleeptime_interval(), and threadutil_update_wait().

#define THREAD_STATUS_SUSPEND   0x0100
 

thread is suspended, can be resumed

Definition at line 326 of file thread.h.

Referenced by jlThread_isDaemon(), and jlThread_setDaemon().

#define THREAD_STATUS_INTERRUPTIBLEIO   0x0200
 

thread is waiting on an interruptable I/O channel in class java.nio.channels.InterruptibleChannel

Definition at line 329 of file thread.h.

#define THREAD_STATUS_NOTIFIED   0x0400
 

thread has been notified

Definition at line 333 of file thread.h.

Referenced by threadutil_update_wait().

#define THREAD_STATUS_INTERRUPTED   0x0800
 

thread has been interrupted

Definition at line 336 of file thread.h.

Referenced by jlThread_interrupt(), jlThread_isAlive(), jlThread_yield(), and threadutil_update_wait().

#define THREAD_STATUS_THREW_EXCEPTION   0x1000
 

thread threw a java.lang.Exception (but NOT a java.lang.Error).

The object type is found in pThrowableEvent and is not rnull.

Definition at line 339 of file thread.h.

Referenced by jlObject_wait4ever(), jlThread_getPriority(), jlThread_interrupted(), jlThread_isAlive(), jlThread_isDaemon(), jlThread_setDaemon(), jlThread_setPriority(), jlThread_start(), objectutil_synchronize(), opcode_run(), thread_exception_setup(), and threadutil_update_wait().

#define THREAD_STATUS_THREW_ERROR   0x2000
 

thread threw a java.lang.Error (but NOT a java.lang.Exception).

The object type is found in pThrowableEvent and is not rnull.

Definition at line 349 of file thread.h.

Referenced by opcode_run(), and thread_exception_setup().

#define THREAD_STATUS_THREW_THROWABLE   0x4000
 

thread threw a java.lang.Throwable of unknowable type.

The object type is found in pThrowableEvent and is not rnull.

Definition at line 359 of file thread.h.

Referenced by opcode_run(), and thread_exception_setup().

#define THREAD_STATUS_THREW_UNCAUGHT   0x8000
 

A java.lang.Throwable of some type was thrown, but not handled by the Java code itself.

Instead, it will be handled by the default java.lang.ThreadGroup.uncaughtException method. The value of pThrowableEvent will be rnull.

Definition at line 368 of file thread.h.

Referenced by opcode_run(), and thread_exception_setup().

#define THREAD_STATE_NEW_DESC   "new"
 

Definition at line 491 of file thread.h.

#define THREAD_STATE_START_DESC   "started"
 

Definition at line 492 of file thread.h.

#define THREAD_STATE_RUNNABLE_DESC   "runnable"
 

Definition at line 493 of file thread.h.

#define THREAD_STATE_RUNNING_DESC   "running"
 

Definition at line 494 of file thread.h.

#define THREAD_STATE_COMPLETE_DESC   "complete"
 

Definition at line 495 of file thread.h.

#define THREAD_STATE_BLOCKINGEVENT_DESC   "blockingevent"
 

Definition at line 496 of file thread.h.

#define THREAD_STATE_BLOCKED_DESC   "blocked"
 

Definition at line 497 of file thread.h.

#define THREAD_STATE_UNBLOCKED_DESC   "unblocked"
 

Definition at line 498 of file thread.h.

#define THREAD_STATE_SYNCHRONIZED_DESC   "synchronized"
 

Definition at line 499 of file thread.h.

#define THREAD_STATE_RELEASE_DESC   "release"
 

Definition at line 500 of file thread.h.

#define THREAD_STATE_WAIT_DESC   "wait"
 

Definition at line 501 of file thread.h.

#define THREAD_STATE_NOTIFY_DESC   "notify"
 

Definition at line 502 of file thread.h.

#define THREAD_STATE_LOCK_DESC   "lock"
 

Definition at line 503 of file thread.h.

#define THREAD_STATE_ACQUIRE_DESC   "acquire"
 

Definition at line 504 of file thread.h.

#define THREAD_STATE_DEAD_DESC   "dead"
 

Definition at line 505 of file thread.h.

#define THREAD_STATE_BADLOGIC_DESC   "bad_logic"
 

Definition at line 506 of file thread.h.

#define THREAD_STATE_ILLEGAL_DESC   "illegal"
 

Definition at line 507 of file thread.h.


Enumeration Type Documentation

enum thread_state_enum
 

Enumerator:
THREAD_STATE_NEW  Newly allocated thread.
THREAD_STATE_START  (transient state) Thread has been started
THREAD_STATE_RUNNABLE  Thread may run JVM code.
THREAD_STATE_RUNNING  Thread is running JVM code.
THREAD_STATE_COMPLETE  (transient state) Thread has finished running JVM code
THREAD_STATE_BLOCKINGEVENT  (transient state) Desist from RUNING JVM code due to I/O request or control request such as sleep() or join()
THREAD_STATE_BLOCKED  Wait for completion of I/O request or control request such as sleep() or join().
THREAD_STATE_UNBLOCKED  (transient state) I/O or control request completed, now can be RUNNABLE again.
THREAD_STATE_SYNCHRONIZED  (transient state) Entered a synchronized block
THREAD_STATE_RELEASE  (transient state) A wait() request released its lock.
THREAD_STATE_WAIT  wait() for a notify(), notifyAll() or interrupt() event.
THREAD_STATE_NOTIFY  Received a notify(), notifyAll() or interrupt() event.
THREAD_STATE_LOCK  Negotiate to ACQUIRE the object's monitor lock again.
THREAD_STATE_ACQUIRE  (transient state) Re-acquired object's monitor lock, may be RUNNABLE again.
THREAD_STATE_DEAD  All work complete, ready to deallocate thread slot.
THREAD_STATE_BADLOGIC  Not in spec, code convenience for dealing with illegal operational conditions.

Definition at line 192 of file thread.h.

enum thread_priority_enum
 

Enumerator:
THREAD_PRIORITY_BAD  Not in spec, but useful in code.
THREAD_PRIORITY_MIN  Minimum thread priority.
THREAD_PRIORITY_NORM  Normal thread priority.
THREAD_PRIORITY_MAX  Maximum thread priority.

Definition at line 258 of file thread.h.


Function Documentation

ARCH_COPYRIGHT_APACHE thread  ,
,
"$URL: https://svn.apache.org/path/name/thread.h $ $Id: thread.h 0 09/28/2005 dlydick $" 
 

const rchar* thread_state_get_name rushort  state  ) 
 

Map state numbers to state names.

Parameters:
state state number per THREAD_STATE_xxx definitions
Returns:
string name of that state
< Highest possible state number

< Highest possible state number

Definition at line 224 of file thread.c.

References EXIT_JVM_THREAD, exit_throw_exception(), JVMCFG_FIRST_THREAD, JVMCFG_MAX_THREADS, JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR, pjvm, rtrue, THREAD, rjvm::thread_new_last, and THREAD_STATUS_INUSE.

Referenced by opcode_run().

jvm_thread_index thread_class_load rchar clsname,
rchar mthname,
rchar mthdesc,
rint  priority,
rboolean  isdaemon,
rboolean  usesystemthread,
rboolean  find_registerNatives
 

Load a class onto a thread during JVM initialization.

Allocate a new thread and load a class (array or non-array), prepare to invoke static methods, and prepare to start thread.

Classes loaded through this function will not be marked as referenced, but will also not be marked for garbage collection, either.

Parameters:
clsname Name of class to load.
mthname Name of method in class.
mthdesc Description of method parameters and return type.
priority THREAD_PRIORITY_xxx value for thread priority.
isdaemon Daemon thread, rtrue or rfalse
usesystemthread Allocate the system thread with thread_new_system() instead of a user thread via thread_new_system(), rtrue or rfalse.
find_registerNatives When rtrue, will return the ordinal for JVMCFG_JLOBJECT_NMO_REGISTER and JVMCFG_JLOBJECT_NMO_UNREGISTER as well as the other ordinals. Once JVM initialization is complete, this should always be rfalse because all future classes should never have local ordinals.
Returns:
Thread index of NEW thread, ready to move to START state, or throw error if no slots.
Exceptions:
JVMCLASS_JAVA_LANG_OUTOFMEMORYERROR if no class slots or thread slots are available..
JVMCLASS_JAVA_LANG_CLASSNOTFOUNDEXCEPTION if class cannot be located..
JVMCLASS_JAVA_LANG_NOSUCHMETHODERROR if the requested method is not found in the class or has no code area..
JVMCLASS_JAVA_LANG_STACKOVERFLOWERROR if loading the class on this thread would overfill the JVM stack for this thread..
< References java.lang.Object < Is an interface, not a class.

< References java.lang.Object

Definition at line 740 of file thread.c.

rvoid thread_init rvoid   ) 
 

rboolean thread_die jvm_thread_index  thridx  ) 
 

Terminate and deallocate a thread that is currently in the DEAD state.

Parameters:
thridx thread index of thread to be deallocated.
Returns:
rtrue if successful, else rfalse.
Mark ONLY fields requiring it, leave rest alone for post-mortem use by developer.

Todo:
Could leave stack in place for post-mortem if it is assumed that there would be a reasonable amount of contents still valid in memory.
< This slot contains a thread

Definition at line 923 of file thread.c.

rvoid thread_shutdown rvoid   ) 
 

int thread_exception_setup jvm_thread_index  thridx  ) 
 

Set up JVM thread-relative exception handler-- implements setjmp(3)/longjmp(3).

Parameters:
thridx Thread table index of thread for which to set up this exception handler.
Returns:
From normal setup, integer THREAD_STATUS_EMPTY. Otherwise, return error code passed in to thread_throw_exception() as shown below.

For internal use only.

setjmp(3) and struct[idx].member do _not_ get along at all:

       int nonlocal_rc =
                    setjmp(*THREAD(thridx).nonlocal_ThrowableEvent);
      
   

To get this working, the nonlocal_ThrowableEvent had to be changed to a pointer and a buffer allocated from heap. This probably is due to the typedef syntax of jmp_buf and a long array, which pointers like. However, instead of playing games with addressing &element[0], a pointer works better because not all jmp_buf implementations wil be a long array.

Definition at line 1077 of file thread.c.

References EXIT_JVM_INTERNAL, exit_throw_exception(), JVMCLASS_JAVA_LANG_INTERNALERROR, THREAD_STATUS_THREW_ERROR, THREAD_STATUS_THREW_EXCEPTION, THREAD_STATUS_THREW_THROWABLE, and THREAD_STATUS_THREW_UNCAUGHT.

Referenced by opcode_run().

rvoid thread_throw_exception jvm_thread_index  thridx,
rushort  thread_status_bits,
rchar exception_name
 

Global handler setup for JVM thread errors and exceptions-- implements setjmp(3).

Parameters:
thridx Thread index of thread where exception occurred.
thread_status_bits Type of exception being generated, typically using one of the following exit codes from the status bits in thread.h per the definition there of each code:

Parameters:
exception_name Null-terminated string name of error or exception class to be invoked as a result of this situation.
Returns:
non-local state restoration from setup via setjmp(3) as stored in exit_LinkageError buffer by exit_init() in jvm_init() before any of these errors could occur. All code invoking this function should use the standard lint(1) comment for "code not reached" as shown after the longjmp(3) function call in the source code of this function: /*NOTREACHED*/
< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< thread threw a java.lang.Error (but NOT a java.lang.Exception). The object type is found in pThrowableEvent and is not rnull.

< thread threw a java.lang.Throwable of unknowable type. The object type is found in pThrowableEvent and is not rnull.

< A java.lang.Throwable of some type was thrown, but not handled by the Java code itself. Instead, it will be handled by the default java.lang.ThreadGroup.uncaughtException method. The value of pThrowableEvent will be rnull.

Definition at line 1130 of file thread.c.

Referenced by jlObject_wait4ever(), jlThread_getPriority(), jlThread_interrupted(), jlThread_isAlive(), jlThread_isDaemon(), jlThread_setDaemon(), jlThread_setPriority(), jlThread_start(), objectutil_synchronize(), and opcode_run().

rboolean threadstate_request_new jvm_thread_index  thridx  ) 
 

Request the NEW thread state.

The NEW state starts the whole state machine for a thread.

< Next requested thread state.

Definition at line 556 of file threadstate.c.

References rtrue, STATE_END, and STATE_REQUEST.

rboolean threadstate_request_start jvm_thread_index  thridx  ) 
 

Request the START state.

The START state can only be entered from NEW.

< This current thread state.

< Next requested thread state.

Definition at line 619 of file threadstate.c.

References STATE_END, STATE_PROCESS, and threadstate_request_runnable().

rboolean threadstate_request_runnable jvm_thread_index  thridx  ) 
 

Request the RUNNABLE state.

The RUNNABLE state can be entered from START, RUNNING, UNBLOCKED, or ACQUIRE.

< This current thread state.

< This current thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

Definition at line 688 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, and THREAD_STATE_RUNNABLE.

Referenced by jlThread_currentThread(), jlThread_sleep(), threadstate_process_synchronized(), and threadstate_request_start().

rboolean threadstate_request_running jvm_thread_index  thridx  ) 
 

Request the RUNNING state.

The RUNNING state can only be entered from RUNNABLE.

The JVM inner execution loop is called from threadstate_process_running(), causing any thread in the RUNNING state to normally keep executing its code from where it left off last time.

< This current thread state.

< Next requested thread state.

Definition at line 774 of file threadstate.c.

References STATE_REQUEST, THIS_STATE, and THREAD_STATE_RUNNING.

rboolean threadstate_request_complete jvm_thread_index  thridx  ) 
 

Request the COMPLETE state.

The COMPLETE state can be entered from NEW or RUNNING or BADLOGIC.

When entered from NEW, it is a so-called "stillborn" thread that was created but never used.

When entered from BADLOGIC, java.lang.Thread.destroy() or java.lang.Thread.stop() was invoked, both of which are dangerous, deprecated methods.

< This current thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

Definition at line 857 of file threadstate.c.

Referenced by opcode_run().

rboolean threadstate_request_blockingevent jvm_thread_index  thridx  ) 
 

Request the BLOCKINGEVENT state.

The BLOCKINGEVENT state can be entered from the RUNNING or BADLOGIC states. This can be caused by java.lang.Thread.sleep() and java.lang.Thread.join() and interruptible I/O operations. Also, deprecated java.lang.Thread.suspend() can go through BADLOGIC to get here.

< This current thread state.

< This current thread state.

< Next requested thread state.

Definition at line 938 of file threadstate.c.

Referenced by jlThread_isDaemon(), and jlThread_setDaemon().

rboolean threadstate_request_blocked jvm_thread_index  thridx  ) 
 

Request the BLOCKED state.

The BLOCKED state can only be entered from BLOCKINGEVENT.

< This current thread state.

< Next requested thread state.

Definition at line 1009 of file threadstate.c.

Referenced by jlThread_isDaemon().

rboolean threadstate_request_unblocked jvm_thread_index  thridx  ) 
 

Request the UNBLOCKED state.

The UNBLOCKED state can only be entered from BLOCKED.

< This current thread state.

< Next requested thread state.

Definition at line 1076 of file threadstate.c.

Referenced by jlThread_isDaemon().

rboolean threadstate_request_synchronized jvm_thread_index  thridx  ) 
 

Request the SYNCHRONIZED state.

The SYNCHRONIZED state can only be entered from RUNNING.

< This current thread state.

< Next requested thread state.

Definition at line 1144 of file threadstate.c.

References threadstate_request_acquire().

Referenced by objectutil_synchronize().

rboolean threadstate_request_release jvm_thread_index  thridx  ) 
 

Request the RELEASE state.

The RELEASE state can only be entered from RUNNING.

< This current thread state.

< Next requested thread state.

Definition at line 1212 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, and THREAD_STATE_COMPLETE.

rboolean threadstate_request_wait jvm_thread_index  thridx  ) 
 

Request the WAIT state.

The WAIT state can only be entered from RELEASE.

< This current thread state.

< Next requested thread state.

Definition at line 1310 of file threadstate.c.

rboolean threadstate_request_notify jvm_thread_index  thridx  ) 
 

Request the NOTIFY state.

The NOTIFY state can only be entered from WAIT.

< This current thread state.

< Next requested thread state.

Definition at line 1379 of file threadstate.c.

Referenced by threadutil_update_wait().

rboolean threadstate_request_lock jvm_thread_index  thridx  ) 
 

Request the LOCK state.

The LOCK state can be entered from SYNCHRONIZED or NOTIFY.

< This current thread state.

< This current thread state.

< Next requested thread state.

Definition at line 1448 of file threadstate.c.

rboolean threadstate_request_acquire jvm_thread_index  thridx  ) 
 

Request the ACQUIRE state.

The ACQUIRE state can only be entered from LOCK.

< This current thread state.

< Next requested thread state.

Definition at line 1548 of file threadstate.c.

Referenced by threadstate_request_synchronized().

rboolean threadstate_request_dead jvm_thread_index  thridx  ) 
 

Request the DEAD state.

The DEAD state can only be entered from COMPLETE.

< This current thread state.

< Next requested thread state.

Definition at line 1617 of file threadstate.c.

rboolean threadstate_request_badlogic jvm_thread_index  thridx  ) 
 

Request the BADLOGIC state.

The BADLOGIC state can be entered from ANY state. It is primarily a diagnostic state, but may be used to gracefully handle java.lang.Thread.destroy() and java.lang.Thread.stop() and java.lang.Thread.suspend() and java.lang.Thread.resume().

< Next requested thread state.

Definition at line 1699 of file threadstate.c.

Referenced by jlThread_currentThread(), and jlThread_setDaemon().

rboolean threadstate_activate_new jvm_thread_index  thridx  ) 
 

Activate the NEW thread state for a new thread.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 570 of file threadstate.c.

rboolean threadstate_activate_start jvm_thread_index  thridx  ) 
 

Activate the START thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 636 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, THREAD_STATE_ACQUIRE, THREAD_STATE_RUNNING, THREAD_STATE_START, and THREAD_STATE_UNBLOCKED.

rboolean threadstate_activate_runnable jvm_thread_index  thridx  ) 
 

Activate the RUNNABLE thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 718 of file threadstate.c.

rboolean threadstate_activate_running jvm_thread_index  thridx  ) 
 

Activate the RUNNING thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 792 of file threadstate.c.

rboolean threadstate_activate_complete jvm_thread_index  thridx  ) 
 

Activate the COMPLETE thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 884 of file threadstate.c.

rboolean threadstate_activate_blockingevent jvm_thread_index  thridx  ) 
 

Activate the BLOCKINGEVENT thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 960 of file threadstate.c.

References rtrue, STATE_ACTIVATE, and STATE_END.

Referenced by jlThread_isDaemon().

rboolean threadstate_activate_blocked jvm_thread_index  thridx  ) 
 

Activate the BLOCKED thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1027 of file threadstate.c.

References rtrue, STATE_ACTIVATE, and STATE_END.

Referenced by jlThread_isDaemon().

rboolean threadstate_activate_unblocked jvm_thread_index  thridx  ) 
 

Activate the UNBLOCKED thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1094 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, THREAD_STATE_NOTIFY, and THREAD_STATE_SYNCHRONIZED.

rboolean threadstate_activate_synchronized jvm_thread_index  thridx  ) 
 

Activate the SYNCHRONIZED thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1162 of file threadstate.c.

rboolean threadstate_activate_release jvm_thread_index  thridx  ) 
 

Activate the RELEASE thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1230 of file threadstate.c.

rboolean threadstate_activate_wait jvm_thread_index  thridx  ) 
 

Activate the WAIT thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1328 of file threadstate.c.

rboolean threadstate_activate_notify jvm_thread_index  thridx  ) 
 

Activate the NOTIFY thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1397 of file threadstate.c.

rboolean threadstate_activate_lock jvm_thread_index  thridx  ) 
 

Activate the LOCK thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1470 of file threadstate.c.

rboolean threadstate_activate_acquire jvm_thread_index  thridx  ) 
 

Activate the ACQUIRE thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1566 of file threadstate.c.

rboolean threadstate_activate_dead jvm_thread_index  thridx  ) 
 

Activate the DEAD thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1635 of file threadstate.c.

rboolean threadstate_activate_badlogic jvm_thread_index  thridx  ) 
 

Activate the BADLOGIC thread state of a thread known to be coming from a valid previous state.

< Next requested thread state.

< Previous actual thread state.

< This current thread state.

< This current thread state.

< Next requested thread state.

< This current thread state.

Definition at line 1714 of file threadstate.c.

Referenced by jlThread_setDaemon().

rboolean threadstate_process_new jvm_thread_index  thridx  ) 
 

Process the NEW thread state.

The NEW state idles until the START state is requested.

< This current thread state.

Definition at line 601 of file threadstate.c.

References rtrue, STATE_ACTIVATE, and STATE_END.

rboolean threadstate_process_start jvm_thread_index  thridx  ) 
 

Process the START thread state.

THIS IS A TRANSIENT STATE! A state change from START to RUNNABLE is requested here.

< This current thread state.

Definition at line 667 of file threadstate.c.

References rtrue, STATE_END, and STATE_PROCESS.

rboolean threadstate_process_runnable jvm_thread_index  thridx  ) 
 

Process the RUNNABLE thread state.

Always try to keep RUNNABLE thread in the RUNNING state. Although not formally a transient state, RUNNABLE indicates that a thread is potentially one that could be RUNNING, thus the attempt to keep it there.

< This current thread state.

Definition at line 751 of file threadstate.c.

References rtrue, STATE_ACTIVATE, and STATE_END.

rboolean threadstate_process_running jvm_thread_index  thridx  ) 
 

Process the RUNNING thread state.

Run the next virtual instruction engine on the current thread from where it left off last time.

Attention:
Notice that the normal way to invoke opcode_run() is in this location, as driven by the JVM outer loop in jvm_run().
< This current thread state.

< Access structures of the thread now running in the JVM.

Definition at line 827 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, and THREAD_STATE_BLOCKINGEVENT.

rboolean threadstate_process_complete jvm_thread_index  thridx  ) 
 

Process the COMPLETE thread state.

THIS IS A TRANSIENT STATE! A state change from COMPLETE to DEAD is requested here.

< This current thread state.

Definition at line 915 of file threadstate.c.

rboolean threadstate_process_blockingevent jvm_thread_index  thridx  ) 
 

Process the BLOCKINGEVENT thread state.

THIS IS A TRANSIENT STATE! A state change from BLOCKINGEVENT to BLOCKED is requested here.

< This current thread state.

Definition at line 991 of file threadstate.c.

References rfalse, THREAD, THREAD_STATUS_JOIN4EVER, and THREAD_STATUS_JOINTIMED.

Referenced by jlThread_isDaemon().

rboolean threadstate_process_blocked jvm_thread_index  thridx  ) 
 

Process the BLOCKED thread state.

The BLOCKED state idles until the UNBLOCKED state is requsted by threadutil_update_blockingevents().

< This current thread state.

Definition at line 1058 of file threadstate.c.

References rtrue, STATE_END, STATE_REQUEST, THIS_STATE, and THREAD_STATE_WAIT.

Referenced by jlThread_isDaemon().

rboolean threadstate_process_unblocked jvm_thread_index  thridx  ) 
 

Process the UNBLOCKED thread state.

THIS IS A TRANSIENT STATE! A state change from UNBLOCKED to RUNNABLE is requested here.

< This current thread state.

Definition at line 1125 of file threadstate.c.

References STATE_PROCESS.

rboolean threadstate_process_synchronized jvm_thread_index  thridx  ) 
 

Process the SYNCHRONIZED thread state.

THIS IS A TRANSIENT STATE! A state change from SYNCHRONIZED to LOCK is requested here.

< This current thread state.

Definition at line 1193 of file threadstate.c.

References STATE_END, STATE_PROCESS, and threadstate_request_runnable().

rboolean threadstate_process_release jvm_thread_index  thridx  ) 
 

Process the RELEASE thread state.

THIS IS A TRANSIENT STATE! A state change from RELEASE to WAIT is requested here. However, this will only occur if this thread holds the lock on the rthread.locktarget object.

< This current thread state.

< thread has unconditionally joined another

< thread has joined another, but is waiting for a finite time

Definition at line 1265 of file threadstate.c.

References rtrue, STATE_END, and STATE_REQUEST.

rboolean threadstate_process_wait jvm_thread_index  thridx  ) 
 

Process the WAIT thread state.

The WAIT state idles until the NOTIFY state is requsted by threadutil_update_wait().

< This current thread state.

Definition at line 1360 of file threadstate.c.

rboolean threadstate_process_notify jvm_thread_index  thridx  ) 
 

Process the NOTIFY thread state.

THIS IS A TRANSIENT STATE! A state change from NOTIFY to LOCK is requested here.

< This current thread state.

Definition at line 1429 of file threadstate.c.

rboolean threadstate_process_lock jvm_thread_index  thridx  ) 
 

Process the LOCK thread state.

THIS IS THE PLACE WHERE THREADS COMPETE FOR AN OBJECT MONITORY LOCK. If a thread is able to successfully run objectutil_synchronize(), then it acquires the MLOCK for that object and moves from the LOCK state forward to the ACQUIRE state.

The LOCK state idles until the ACQUIRE state is requsted by threadutil_update_lock().

< This current thread state.

Definition at line 1508 of file threadstate.c.

rboolean threadstate_process_acquire jvm_thread_index  thridx  ) 
 

Process the ACQUIRE thread state.

THIS IS A TRANSIENT STATE! A state change from ACQUIRE to RUNABLE is requested here.

< This current thread state.

Definition at line 1598 of file threadstate.c.

rboolean threadstate_process_dead jvm_thread_index  thridx  ) 
 

Process the DEAD thread state.

Bogus, yet true: THIS IS A TRANSIENT STATE! the usual message about this state applies, yet the target state is the "not used" condition, so it may also be considered inapplicable. Here 'tis:

THIS IS A TRANSIENT STATE! A state change from DEAD to "not used" is requested here.

So how is this statement true? Because thread_die() is called once the thread enters this condition, removing it from the array of active thread table entries.

< This current thread state.

Definition at line 1676 of file threadstate.c.

rboolean threadstate_process_badlogic jvm_thread_index  thridx  ) 
 

Process the BADLOGIC thread state.

The BADLOGIC state idles until another state is requested. An "Idle forever" error message might be printed by code that invoked this state. If desired, this state can be moved forward to COMPLETE or BLOCKINGEVENT. Part of the request logic for these states is to permit entrance from the BADLOGIC state.

< This current thread state.

Definition at line 1750 of file threadstate.c.

rvoid threadutil_update_sleeptime_interval rvoid   ) 
 

Update the interval timer for this thread from java.lang.Thread.sleep() or from a timed java.lang.Thread.wait() or java.lang.Thread.join().

This function is designed to be invoked from the timeslice interrupt handler and only from thence. It DOES NOT handle (millisec, nanosec) resolution, only millisecond resolution.

Parameters: rvoid

Returns:
rvoid
< This slot contains a thread

< thread is sleeping

< thread has joined another, but is waiting for a finite time

< thread is waiting, but finite time

Definition at line 84 of file threadutil.c.

References jvm_thread_index_null, JVMCFG_MAX_THREADS, pjvm, rjvm::sleeplock, THREAD, THREAD_STATUS_INUSE, THREAD_STATUS_JOINTIMED, THREAD_STATUS_SLEEP, and THREAD_STATUS_WAITTIMED.

Referenced by timeslice_tick().

rvoid threadutil_update_blockingevents jvm_thread_index  thridxcurr  ) 
 

Complete the UNtimed Thread.join() request and allow threads that have joined this one to resume execution.

This function is typically called when a thread enters the COMPLETE state after finishing its JVM execution.

Review state of thread table, looking for the following conditions. For those that meet them, move thread out of given state and forward to next state. Three functions are used, depending on the current state, threadutil_update_blockingevent() and threadutil_update_wait() and threadutil_update_lock():

   Condition:         Current state: Next state:  threadutil_update_YYY:
   ----------         -------------- -----------  ----------------------
  
   Thread.join()      COMPLETE       N/C              _blockingevents()
   (forever, where
   current thread
   is COMPLETE, and
   target thread is
   BLOCKED, and is
   moved to UNBLOCKED)
  
   Thread.join(n)     COMPLETE       N/C              _blockingevents()
   (timed, where
   n has expired
   on current
   thread or it is
   COMPLETE, and
   target thread
   is BLOCKED, and
   is moved to
   UNBLOCKED)
  
   Thread.sleep(n)    BLOCKED        UNBLOCKED        _blockingevents()
   (n has expired on
   current thread)
  
   Interruptible I/O  BLOCKED        UNBLOCKED        _blockingevents()
   from class
   java.nio.channels
   .InterruptibleChannel
  
   Object.wait()      WAIT           NOTIFY           _wait()
   (forever on
   current thread,
   where target object
   lock was released)
  
   Object.wait(n)     WAIT           NOTIFY           _wait()
   (timed, where
   @c @b n
   has expired on
   current thread
   or target object
   lock was released)
  
   One of:            LOCK           ACQUIRE          _lock()
   Object.notify()
   Object.notifyAll()
   Thread.interrupt()
   synchronized(Object)
   ... put thread
   into LOCK state.
   Now it will
   negotiate to
   ACQUIRE its
   object's
   monitor lock.
   
  
   Thread.suspend()   ANY            BLOCKED        threadutil_suspend()
  
   Thread.resume()    BLOCKED        UNBLOCKED       threadutil_resume()
   moves a
   Thread.suspend()
   thread forward
   to UNBLOCKED
  
   

With the exception of threadutil_suspend() and threadutil_resume(), these functions is designed to be invoked from the JVM outer loop. CAVEAT EMPTOR: Those two functions are deprecated. Use at your own risk!

Todo:
Interruptible from class java.nio.channels.InterruptibleChannel
Parameters:
thridxcurr Thread for which to examine state changes
Returns:
rvoid
< This slot contains a thread

Todo:
interruptible I/O req's
< thread is sleeping

< thread is sleeping

< thread has been interrupted

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

Todo:
First pass guess at interruptible I/O
< thread is waiting on an interruptable I/O channel in class java.nio.channels.InterruptibleChannel

Check if Thread.interrupt() was thrown against the interruptible I/O operation on this thread.

Todo:
Is this the correct way to handle interruptible I/O events? Also need to throw the exception in JVM outer loop.
< thread has been interrupted

< thread is waiting on an interruptable I/O channel in class java.nio.channels.InterruptibleChannel

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< thread has unconditionally joined another

< thread has unconditionally joined another

< thread has been interrupted

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< thread has joined another, but is waiting for a finite time

< thread has joined another, but is waiting for a finite time

< thread has been interrupted

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

Definition at line 221 of file threadutil.c.

rvoid threadutil_update_wait jvm_thread_index  thridxcurr  ) 
 

< This slot contains a thread

< thread is unconditionally waiting

< thread has been interrupted

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< thread is unconditionally waiting

< thread has been notified

< thread has been notified

< thread is unconditionally waiting

< thread is waiting, but finite time

< thread is waiting, but finite time

< thread has been interrupted

< thread has been interrupted

< thread threw a java.lang.Exception (but NOT a java.lang.Error). The object type is found in pThrowableEvent and is not rnull.

< thread is waiting, but finite time

< thread has been notified

< thread has been notified

< thread is waiting, but finite time

Definition at line 444 of file threadutil.c.

References JVMCLASS_JAVA_LANG_INTERRUPTEDEXCEPTION, THREAD, THREAD_STATUS_INTERRUPTED, THREAD_STATUS_NOTIFIED, THREAD_STATUS_THREW_EXCEPTION, THREAD_STATUS_WAITTIMED, threadstate_request_notify(), and timeslice_get_thread_sleeptime().

rvoid threadutil_update_lock jvm_thread_index  thridxcurr  ) 
 

< This slot contains a thread

< Object monitor locked by mlock_thridx

< thread is unconditionally waiting

Definition at line 575 of file threadutil.c.

rboolean threadutil_holds_lock jvm_thread_index  thridx,
jvm_object_hash  objhashlock
 

Examine an object to see if a thread owns its monitor lock.

Parameters:
thridx Thread table index of thread to compare with.
objhashlock Object table hash of object to examine.
Returns:
rtrue if this thread owns this object's monitor lock.
< This slot contains an object

< NULL object (only 1 exists in normal use, any else besides the JVMCFG_NULL_OBJECT is an object slot now being initialized.)

< This slot contains a thread

< Null thread (only 1 exists in normal use, any else besides the JVMCFG_NULL_THREAD is a thread slot that is being initialized.)

< Object monitor locked by mlock_thridx

< thread is unconditionally waiting

< thread is waiting, but finite time

Definition at line 640 of file threadutil.c.

Referenced by jlThread_interrupted().


Variable Documentation

const rchar* thread_state_name
 


Generated on Fri Sep 30 19:00:53 2005 by  doxygen 1.4.4