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.
Definition in file thread.c.
#include "arch.h"
#include <strings.h>
#include "jvmcfg.h"
#include "cfmacros.h"
#include "classfile.h"
#include "exit.h"
#include "gc.h"
#include "jvm.h"
#include "jvmclass.h"
#include "linkage.h"
#include "method.h"
#include "util.h"
#include "utf.h"
Go to the source code of this file.
Thread allocation and loading. | ||||||||||||||||||||||||||||
Allocate a new thread from the thread area and load a class to run on it.
Activity on the system thread JVMCFG_SYSTEM_THREAD will not attempt to load a As a variation, allocate the system thread (JVMCFG_SYSTEM_THREAD) for an internal task. This method-- thread_new_common()-- is the common routine, where thread_new() is the general-purpose function and thread_new_system() is for loading a class onto the system thread.
| ||||||||||||||||||||||||||||
static jvm_thread_index | thread_new (jvm_class_index clsidx, jvm_method_index mthidx, jvm_attribute_index codeatridx, jvm_attribute_index excpatridx, rint priority, rboolean isdaemon) | |||||||||||||||||||||||||||
Allocate a new thread from the thread area and load a class to run on it. | ||||||||||||||||||||||||||||
static jvm_thread_index | thread_new_common (jvm_thread_index thridx, jvm_class_index clsidx, jvm_method_index mthidx, jvm_attribute_index codeatridx, jvm_attribute_index excpatridx, rint priority, rboolean isdaemon) | |||||||||||||||||||||||||||
Common function to load a class on a thread to be run. | ||||||||||||||||||||||||||||
static jvm_thread_index | thread_new_system (jvm_class_index clsidx, jvm_method_index mthidx, jvm_attribute_index codeatridx, jvm_attribute_index excpatridx, rint priority, rboolean isdaemon) | |||||||||||||||||||||||||||
Reserve the system thread and load a class to run on it. | ||||||||||||||||||||||||||||
Functions | ||||||||||||||||||||||||||||
static jvm_thread_index | thread_allocate_slot (rvoid) | |||||||||||||||||||||||||||
Locate an unused thread table slot for a new thread. | ||||||||||||||||||||||||||||
static void | thread_c_dummy (void) | |||||||||||||||||||||||||||
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 () | |||||||||||||||||||||||||||
Initialize the thread area of the JVM model. | ||||||||||||||||||||||||||||
rvoid | thread_shutdown () | |||||||||||||||||||||||||||
Shut down the thread area of the JVM model at the end of JVM execution. | ||||||||||||||||||||||||||||
const rchar * | thread_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). | ||||||||||||||||||||||||||||
Variables | ||||||||||||||||||||||||||||
static char * | thread_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/thread.c $ $Id: thread.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." | |||||||||||||||||||||||||||
const rchar * | thread_state_names [THREAD_STATE_BADLOGIC+1+1] | |||||||||||||||||||||||||||
Look up table for names of thread states. |
|
|
|
Initialize the thread area of the JVM model. Parameters: rvoid
< Access structures of the thread now running in the JVM. < Access structures of the thread now running in the JVM. < Access structures of the thread now running in the JVM. < Arbitrary max thread name length
< This slot is available for use. DO NOT CHANGE since this is also the normal
< Null thread (only 1 exists in normal use, any else besides the JVMCFG_NULL_THREAD is a thread slot that is being initialized.)
< This slot is available for use. DO NOT CHANGE since this is also the normal < This slot contains a thread < Access structures of the thread now running in the JVM. Definition at line 70 of file thread.c. References CURRENT_THREAD, HEAP_GET_DATA, jvm_attribute_index_bad, jvm_class_index_null, jvm_method_index_bad, jvm_object_hash_null, jvm_pc_offset_bad, jvm_thread_index_null, jvm_thread_initialized, JVMCFG_GC_THREAD, JVMCFG_MAX_THREADS, JVMCFG_NULL_SP, JVMCFG_SYSTEM_THREAD, pjvm, PUT_PC_IMMEDIATE, rfalse, rnull, rtrue, sprintfLocal(), THREAD, THREAD_NAME_MAX_LEN, rjvm::thread_new_last, THREAD_PRIORITY_MAX, THREAD_PRIORITY_MIN, THREAD_STATE_DEAD, THREAD_STATE_NEW, THREAD_STATUS_EMPTY, THREAD_STATUS_INUSE, and THREAD_STATUS_NULL. |
|
Map state numbers to state names.
< 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(). |
|
Locate an unused thread table slot for a new thread. Parameters: rvoid
< 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.) |
|
Common function to load a class on a thread to be run. Given a thread index, load a method onto it to be run. Do not use this function to load a method onto a thread that has existing JVM execution active because the stack is initialized and the method entry point loaded into the PC. See opcode_run() for examples of how to accomplish this in other ways. < 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.)
If no stack overflow would occur during execution, continue to load up a new thread. Unless this class will run on the system thread, start out by generating a new
setjmp(3) return code from thread_exception_setup()< This slot is available for use < Not stated in spec, but implied < Magic number for class files alias
< Null thread (only 1 exists in normal use, any else besides the JVMCFG_NULL_THREAD is a thread slot that is being initialized.) < Start PC location Definition at line 406 of file thread.c. References jvm_object_hash_null, and THREAD. |
|
Reserve the system thread and load a class to run on it. Reserve the system thread specifically-- see description above for thread_new_common() < This slot contains a thread |
|
Allocate a new thread from the thread area and load a class to run on it. General-purpuse version-- see description above for thread_new_common() Definition at line 649 of file thread.c. References ACC_INTERFACE, ClassFile::access_flags, class_find_by_prchar(), class_load_from_prchar(), CLASS_OBJECT_LINKAGE, CONSTANT_CP_DEFAULT_INDEX, EXIT_JVM_CLASS, exit_throw_exception(), JVMCLASS_JAVA_LANG_INCOMPATIBLECLASSCHANGEERROR, PTR_CP1_CLASS_NAME_STRNAME, rnull, and ClassFile::super_class. |
|
Load a class onto a thread during JVM initialization.
Allocate a new thread and load a class (array or non-array), prepare to invoke Classes loaded through this function will not be marked as referenced, but will also not be marked for garbage collection, either.
java.lang.Object < Is an interface, not a class.
< References |
|
Terminate and deallocate a thread that is currently in the DEAD state.
|
|
Shut down the thread area of the JVM model at the end of JVM execution. Parameters: rvoid
alias Definition at line 959 of file thread.c. References HEAP_FREE_STACK, and THREAD. |
|
Set up JVM thread-relative exception handler-- implements
For internal use only.
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 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(). |
|
Global handler setup for JVM thread errors and exceptions-- implements
java.lang.Exception (but NOT a java.lang.Error) . The object type is found in pThrowableEvent and is not rnull.
< thread threw a
< thread threw a
< A 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(). |
|
|
|
Initial value: { "new" , "started" , "runnable" , "running" , "complete" , "blockingevent" , "blocked" , "unblocked" , "synchronized" , "release" , "wait" , "notify" , "lock" , "acquire" , "dead" , "bad_logic" , "illegal" }
|