For internal use only.
This file also serves the dual purpose as a catch-all for development experiments. Due to the fact that the implementation of the Java thread and the supporting rthread structure is deeply embedded in the core of the development of this software, this file has contents that come and go during development. Some functions get staged here before deciding where they really go; some are interim functions for debugging, some were glue that eventually went away. Be careful to remove prototypes to such functions from the appropriate header file.
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 threadutil.c.
#include "arch.h"
#include "jvmcfg.h"
#include "cfmacros.h"
#include "classfile.h"
#include "jvm.h"
#include "jvmclass.h"
#include "util.h"
Go to the source code of this file.
Functions | |
static void | threadutil_c_dummy (void) |
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) |
Variables | |
static char * | threadutil_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/threadutil.c $ $Id: threadutil.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." |
|
Definition at line 56 of file threadutil.c. |
|
Update the interval timer for this thread from 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
< 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(). |
|
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!
< thread is sleeping < thread has been interrupted < thread has been interrupted
< thread threw a
Check if Thread.interrupt() was thrown against the interruptible I/O operation on this thread.
< thread is waiting on an interruptable I/O channel in class java.nio.channels.InterruptibleChannel < thread has been interrupted
< thread threw a < thread has unconditionally joined another < thread has unconditionally joined another < thread has been interrupted < thread has been interrupted
< thread threw a < 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 Definition at line 221 of file threadutil.c. |
|
< This slot contains a thread < thread is unconditionally waiting < thread has been interrupted < thread has been interrupted
< thread threw a < 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 < 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(). |
|
< This slot contains a thread < Object monitor locked by mlock_thridx < thread is unconditionally waiting Definition at line 575 of file threadutil.c. |
|
Examine an object to see if a thread owns its monitor lock.
< 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(). |
|
Definition at line 56 of file threadutil.c. |