Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: threads.c 7904 2007-05-14 13:29:32Z twisti $
+ $Id: threads.c 7963 2007-05-24 10:21:16Z twisti $
*/
#endif
/* global mutex for the threads table */
-static pthread_mutex_t mutex_threads_table;
+static pthread_mutex_t mutex_threads_list;
/* global mutex for stop-the-world */
static pthread_mutex_t stopworldlock;
#if !defined(__DARWIN__)
/* Caller must hold threadlistlock */
-static void threads_cast_sendsignals(int sig)
+static s4 threads_cast_sendsignals(s4 sig)
{
threadobject *t;
threadobject *self;
+ s4 count;
self = THREADOBJECT;
/* iterate over all started threads */
- for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
+ count = 0;
+
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
/* don't send the signal to ourself */
- if (t != self)
- pthread_kill(t->tid, sig);
+ if (t == self)
+ continue;
+
+ /* don't send the signal to NEW threads (because they are not
+ completely initialized) */
+
+ if (t->state == THREAD_STATE_NEW)
+ continue;
+
+ /* send the signal */
+
+ pthread_kill(t->tid, sig);
+
+ /* increase threads count */
+
+ count++;
}
+
+ return count;
}
#else
void threads_cast_stopworld(void)
{
#if !defined(__DARWIN__) && !defined(__CYGWIN__)
- int count, i;
+ s4 count, i;
#endif
lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING);
- /* lock the threads table */
+ /* lock the threads lists */
- threads_table_lock();
+ threads_list_lock();
#if defined(__DARWIN__)
threads_cast_darwinstop();
#else
/* send all threads the suspend signal */
- threads_cast_sendsignals(GC_signum1());
-
- /* wait for all threads to suspend (except the current one) */
+ count = threads_cast_sendsignals(GC_signum1());
- count = threads_table_get_threads() - 1;
+ /* wait for all threads signaled to suspend */
for (i = 0; i < count; i++)
threads_sem_wait(&suspend_ack);
#endif
- /* unlock the threads table */
-
- threads_table_unlock();
+ /* ATTENTION: Don't unlock the threads-lists here so that
+ non-signaled NEW threads can't change their state and execute
+ code. */
}
+
void threads_cast_startworld(void)
{
- /* lock the threads table */
-
- threads_table_lock();
-
#if defined(__DARWIN__)
threads_cast_darwinresume();
#elif defined(__MIPS__)
/* TODO */
assert(0);
#else
- threads_cast_sendsignals(GC_signum2());
+ (void) threads_cast_sendsignals(GC_signum2());
#endif
- /* unlock the threads table */
+ /* unlock the threads lists */
- threads_table_unlock();
+ threads_list_unlock();
unlock_stopworld();
}
void threads_impl_table_init(void)
{
- pthread_mutex_init(&mutex_threads_table, NULL);
+ pthread_mutex_init(&mutex_threads_list, NULL);
}
-/* threads_table_lock **********************************************************
+/* threads_list_lock ***********************************************************
Enter the threads table mutex.
NOTE: We need this function as we can't use an internal lock for
- the threads table because the thread's lock is initialized in
+ the threads lists because the thread's lock is initialized in
threads_table_add (when we have the thread index), but we
already need the lock at the entry of the function.
*******************************************************************************/
-void threads_table_lock(void)
+void threads_list_lock(void)
{
- if (pthread_mutex_lock(&mutex_threads_table) != 0)
+ if (pthread_mutex_lock(&mutex_threads_list) != 0)
vm_abort("threads_table_lock: pthread_mutex_lock failed: %s",
strerror(errno));
}
-/* threads_table_unlock ********************************************************
+/* threads_list_unlock *********************************************************
- Leave the threads table mutex.
+ Leave the threads list mutex.
*******************************************************************************/
-void threads_table_unlock(void)
+void threads_list_unlock(void)
{
- if (pthread_mutex_unlock(&mutex_threads_table) != 0)
+ if (pthread_mutex_unlock(&mutex_threads_list) != 0)
vm_abort("threads_table_unlock: pthread_mutex_unlock failed: %s",
strerror(errno));
}
return false;
/* Get the main-thread (NOTE: The main threads is always the first
- thread in the table). */
+ thread in the list). */
- mainthread = threads_table_first();
+ mainthread = threads_list_first();
/* create a java.lang.Thread for the main thread */
threads_startup.
IN:
- t............the argument passed to pthread_create, ie. a pointer to
+ arg..........the argument passed to pthread_create, ie. a pointer to
a startupinfo struct. CAUTION: When the `psem` semaphore
is posted, the startupinfo struct becomes invalid! (It
is allocated on the stack of threads_start_thread.)
******************************************************************************/
-static void *threads_startup_thread(void *t)
+static void *threads_startup_thread(void *arg)
{
startupinfo *startup;
threadobject *thread;
/* get passed startupinfo structure and the values in there */
- startup = t;
- t = NULL; /* make sure it's not used wrongly */
+ startup = arg;
thread = startup->thread;
function = startup->function;
threads_set_current_threadobject(thread);
- /* thread is running */
+ /* set our priority */
- thread->state = THREAD_STATE_RUNNABLE;
+ threads_set_thread_priority(thread->tid, thread->object->priority);
- /* insert the thread into the threads table */
+ /* thread is completely initialized */
- threads_table_add(thread);
+ threads_thread_state_runnable(thread);
/* tell threads_startup_thread that we registered ourselves */
/* CAUTION: *startup becomes invalid with this! */
startup = NULL;
threads_sem_post(psem);
- /* set our priority */
-
- threads_set_thread_priority(thread->tid, thread->object->priority);
-
#if defined(ENABLE_INTRP)
/* set interpreter stack */
if (isdaemon)
thread->flags |= THREAD_FLAG_DAEMON;
- thread->state = THREAD_STATE_RUNNABLE;
+ /* thread is completely initialized */
- /* insert the thread into the threads table */
-
- threads_table_add(thread);
+ threads_thread_state_runnable(thread);
#if !defined(NDEBUG)
if (opt_verbosethreads) {
#if defined(ENABLE_JAVASE)
/* get the main thread */
- mainthread = threads_table_first();
+ mainthread = threads_list_first();
group = mainthread->object->group;
#endif
}
/* thread is terminated */
- thread->state = THREAD_STATE_TERMINATED;
-
- /* remove thread from the threads table */
-
- threads_table_remove(thread);
+ threads_thread_state_terminated(thread);
#if !defined(NDEBUG)
if (opt_verbosethreads) {
void threads_join_all_threads(void)
{
- threadobject *thread;
+ threadobject *t;
/* get current thread */
- thread = THREADOBJECT;
+ t = THREADOBJECT;
/* this thread is waiting for all non-daemon threads to exit */
- thread->state = THREAD_STATE_WAITING;
+ threads_thread_state_waiting(t);
/* enter join mutex */
compare against 1 because the current (main thread) is also a
non-daemon thread. */
- while (threads_table_get_non_daemons() > 1)
+ while (threads_list_get_non_daemons() > 1)
pthread_cond_wait(&cond_join, &mutex_join);
/* leave join mutex */
while (!thread->interrupted && !thread->signaled
&& threads_current_time_is_earlier_than(wakeupTime))
{
- thread->state = THREAD_STATE_TIMED_WAITING;
+ threads_thread_state_timed_waiting(thread);
pthread_cond_timedwait(&thread->waitcond, &thread->waitmutex,
wakeupTime);
- thread->state = THREAD_STATE_RUNNABLE;
+ threads_thread_state_runnable(thread);
}
}
else {
/* no timeout */
while (!thread->interrupted && !thread->signaled) {
- thread->state = THREAD_STATE_WAITING;
+ threads_thread_state_waiting(thread);
pthread_cond_wait(&thread->waitcond, &thread->waitmutex);
- thread->state = THREAD_STATE_RUNNABLE;
+ threads_thread_state_runnable(thread);
}
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: threads-common.c 7914 2007-05-18 14:17:34Z twisti $
+ $Id: threads-common.c 7963 2007-05-24 10:21:16Z twisti $
*/
#include "vm/types.h"
+#include "mm/memory.h"
+
#include "native/jni.h"
#include "native/include/java_lang_Object.h"
#include "threads/lock-common.h"
#include "threads/threads-common.h"
+#include "toolbox/list.h"
+
#include "vm/builtin.h"
#include "vm/stringlocal.h"
#include "vm/vm.h"
/* global variables ***********************************************************/
-/* global threads table */
-static threads_table_t threads_table;
-
-
-/* prototypes *****************************************************************/
+/* global threads list */
+static list_t *list_threads;
-static void threads_table_init(threadobject *mainthread);
+/* global threads free-list */
+static list_t *list_threads_free;
/* threads_preinit *************************************************************
{
threadobject *mainthread;
+ /* initialize the threads lists */
+
+ list_threads = list_create(OFFSET(threadobject, linkage));
+ list_threads_free = list_create(OFFSET(threadobject, linkage));
+
/* Initialize the threads implementation (sets the thinlock on the
main thread). */
mainthread = threads_thread_new();
- mainthread->object = NULL;
- mainthread->index = 1;
- mainthread->thinlock = lock_pre_compute_thinlock(mainthread->index);
-
/* thread is a Java thread and running */
mainthread->flags = THREAD_FLAG_JAVA;
/* store the internal thread data-structure in the TSD */
threads_set_current_threadobject(mainthread);
-
- /* initialize the threads table with the main-thread */
-
- threads_table_init(mainthread);
/* initialize locking subsystems */
}
-/* threads_table_init **********************************************************
-
- Initialize the global threads table. We initialize the table with
- the main-thread, which has always the index 1.
-
- IN:
- mainthread....the main-thread
-
-*******************************************************************************/
-
-#define THREADS_INITIAL_TABLE_SIZE 8
-
-static void threads_table_init(threadobject *mainthread)
-{
- threads_table_entry_t *ttemain;
- s4 size;
- s4 i;
-
- /* initialize the threads table lock */
-
- threads_impl_table_init();
-
- /* initialize the table */
-
- size = THREADS_INITIAL_TABLE_SIZE;
-
- threads_table.table = MNEW(threads_table_entry_t, size);
- threads_table.size = size;
- threads_table.used = 0;
- threads_table.daemons = 0;
-
- /* Link the entries in a freelist. Skip 2 entries: 0 is the
- free-list header and 1 is the main thread. */
-
- for (i = 2; i < size; i++) {
- threads_table.table[i].thread = NULL;
- threads_table.table[i].next = i + 1;
- }
-
- threads_table.table[0].next = 2;
-
- /* terminate the freelist */
-
- threads_table.table[size - 1].next = 0; /* index 0 is never free */
-
- /* insert the main-thread */
-
- ttemain = &(threads_table.table[1]);
-
- ttemain->thread = mainthread;
- ttemain->next = 0;
-
- /* now 1 entry is used */
-
- threads_table.used = 1;
-}
-
-
-/* threads_table_add ***********************************************************
+/* threads_list_first **********************************************************
- Add a thread to the global threads table. The index is entered in the
- threadobject. The thinlock value for the thread is pre-computed.
+ Return the first entry in the threads list.
- IN:
- thread............the thread to add
-
- RETURN VALUE:
- The table index for the newly added thread. This value has also been
- entered in the threadobject.
+ NOTE: This function does not lock the lists.
*******************************************************************************/
-s4 threads_table_add(threadobject *thread)
+threadobject *threads_list_first(void)
{
- threads_table_entry_t *ttefree;
- threads_table_entry_t *ttemain;
- threads_table_entry_t *tte;
- s4 index;
- s4 oldsize;
- s4 newsize;
- s4 i;
-
- /* lock the threads table */
-
- threads_table_lock();
-
- /* get free and main entry */
-
- ttefree = &(threads_table.table[0]);
- ttemain = &(threads_table.table[1]);
-
- /* get the next free index */
-
- index = ttefree->next;
-
- /* no entry free anymore? resize the table */
-
- if (index == 0) {
- /* we must grow the table */
-
- oldsize = threads_table.size;
- newsize = oldsize * 2;
-
- threads_table.table = MREALLOC(threads_table.table,
- threads_table_entry_t, oldsize, newsize);
- threads_table.size = newsize;
-
- /* the addresses have changed, get them again */
-
- ttefree = &(threads_table.table[0]);
- ttemain = &(threads_table.table[1]);
-
- /* link the new entries to a free list */
-
- for (i = oldsize; i < newsize; i++) {
- threads_table.table[i].thread = NULL;
- threads_table.table[i].next = i + 1;
- }
-
- ttefree->next = oldsize;
-
- /* terminate the freelist */
-
- threads_table.table[newsize - 1].next = 0; /* index 0 is never free */
-
- /* use the first of the new entries */
-
- index = ttefree->next;
- }
-
- /* get the entry with the assigned index */
-
- tte = &(threads_table.table[index]);
-
- /* store the next free index into the free-list header */
-
- ttefree->next = tte->next;
-
- /* store the thread in the table */
-
- tte->thread = thread;
-
- /* link the new entry into the used-list */
-
- tte->next = ttemain->next;
- ttemain->next = index;
-
- /* update the counters */
-
- threads_table.used++;
-
- if (thread->flags & THREAD_FLAG_DAEMON)
- threads_table.daemons++;
-
- assert(threads_table.used < threads_table.size);
-
- /* set the thread variables */
-
- thread->index = index;
- thread->thinlock = lock_pre_compute_thinlock(index);
-
- /* unlock the threads table */
-
- threads_table_unlock();
-
- return index;
-}
-
-
-/* threads_table_remove *******************************************************
-
- Remove a thread from the global threads table.
-
- IN:
- thread............the thread to remove
-
-******************************************************************************/
-
-void threads_table_remove(threadobject *thread)
-{
- threads_table_entry_t *ttefree;
- threads_table_entry_t *tte;
- s4 index;
- s4 i;
-
- /* lock the threads table */
-
- threads_table_lock();
-
- /* get the free entry */
-
- ttefree = &(threads_table.table[0]);
-
- /* get the current entry */
-
- index = thread->index;
- tte = &(threads_table.table[index]);
-
- assert(tte->thread == thread);
-
- /* Find the entry which has the one to be removed as next entry (I
- think it's better to do it at the removal in linear time than
- to have a list or to do it every time we iterate over all
- threads). */
-
- for (i = 0; i < threads_table.size; i++) {
- if (threads_table.table[i].next == index) {
- threads_table.table[i].next = tte->next;
- break;
- }
- }
-
- /* clear the thread pointer in the entry */
-
- tte->thread = NULL;
-
- /* this entry is free now, add it to the free-list */
-
- tte->next = ttefree->next;
- ttefree->next = index;
-
- /* update the counters */
-
- threads_table.used--;
-
- if (thread->flags & THREAD_FLAG_DAEMON)
- threads_table.daemons--;
-
- assert(threads_table.used >= 0);
-
- /* delete the index in the threadobject to discover bugs */
-#if !defined(NDEBUG)
- thread->index = 0;
-#endif
+ threadobject *t;
- /* unlock the threads table */
+ t = list_first_unsynced(list_threads);
- threads_table_unlock();
+ return t;
}
-/* threads_table_get ***********************************************************
+/* threads_list_next ***********************************************************
- Return the thread of the given table-entry index.
+ Return the next entry in the threads list.
- NOTE: It is valid to pass and index of 0, as this entry is the
- free-list header where the thread pointer is always NULL and
- this is thre expected behavior.
-
- NOTE: This function does not lock the table.
+ NOTE: This function does not lock the lists.
*******************************************************************************/
-static threadobject *threads_table_get(s4 index)
+threadobject *threads_list_next(threadobject *t)
{
- threadobject *thread;
+ threadobject *next;
- /* get the requested entry */
+ next = list_next_unsynced(list_threads, t);
- assert((index >= 0) && (index < threads_table.size));
-
- thread = threads_table.table[index].thread;
-
- return thread;
+ return next;
}
-/* threads_table_get_threads ***************************************************
+/* threads_list_get_non_daemons ************************************************
- Return the number of running threads.
+ Return the number of non-daemon threads.
- NOTE: This function does not lock the table.
+ NOTE: This function does a linear-search over the threads list,
+ because it's only used for joining the threads.
*******************************************************************************/
-s4 threads_table_get_threads(void)
+s4 threads_list_get_non_daemons(void)
{
- return threads_table.used;
-}
-
-
-/* threads_table_get_non_daemons ***********************************************
-
- Return the number of non-daemon threads.
-
-*******************************************************************************/
+ threadobject *t;
+ s4 nondaemons;
-s4 threads_table_get_non_daemons(void)
-{
- s4 nondaemons;
+ /* lock the threads lists */
- /* lock the threads table */
+ threads_list_lock();
- threads_table_lock();
+ nondaemons = 0;
- nondaemons = threads_table.used - threads_table.daemons;
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
+ if (!(t->flags & THREAD_FLAG_DAEMON))
+ nondaemons++;
+ }
- /* unlock the threads table */
+ /* unlock the threads lists */
- threads_table_unlock();
+ threads_list_unlock();
return nondaemons;
}
-/* threads_table_first *********************************************************
-
- Return the first thread of the threads table.
-
- NOTE: This is always the entry with index 1 and must be the main
- thread.
+/* threads_thread_new **********************************************************
- NOTE: This function does not lock the table.
+ Allocates and initializes an internal thread data-structure and
+ adds it to the threads list.
*******************************************************************************/
-threadobject *threads_table_first(void)
+threadobject *threads_thread_new(void)
{
- threadobject *thread;
-
- /* get the requested entry */
-
- thread = threads_table_get(1);
-
- return thread;
-}
-
+ threadobject *t;
-/* threads_table_next **********************************************************
+ /* lock the threads-lists */
- Return the next thread of the threads table relative to the passed
- one.
+ threads_list_lock();
- NOTE: This function does not lock the table.
+ /* try to get a thread from the free-list */
-*******************************************************************************/
+ t = list_first_unsynced(list_threads_free);
-threadobject *threads_table_next(threadobject *thread)
-{
- threads_table_entry_t *tte;
- threadobject *next;
- s4 index;
+ /* is a free thread available? */
- index = thread->index;
+ if (t != NULL) {
+ /* yes, remove it from the free list */
- /* get the passed entry */
+ list_remove_unsynced(list_threads_free, t);
+ }
+ else {
+ /* no, allocate a new one */
- assert((index > 0) && (index < threads_table.size));
+#if defined(ENABLE_GC_BOEHM)
+ t = GCNEW_UNCOLLECTABLE(threadobject, 1);
+#else
+ t = NEW(threadobject);
+#endif
- tte = &(threads_table.table[index]);
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ size_threadobject += sizeof(threadobject);
+#endif
- /* get the requested entry */
+ /* clear memory */
- next = threads_table_get(tte->next);
+ MZERO(t, threadobject, 1);
- return next;
-}
+ /* set the threads-index */
+ t->index = list_threads->size + 1;
+ }
-/* threads_table_dump *********************************************************
+ /* pre-compute the thinlock-word */
- Dump the threads table for debugging purposes.
+ assert(t->index != 0);
-******************************************************************************/
+ t->thinlock = lock_pre_compute_thinlock(t->index);
+ t->state = THREAD_STATE_NEW;
-#if !defined(NDEBUG)
-void threads_table_dump(void)
-{
- s4 i;
- s4 size;
- ptrint index;
+ /* initialize the implementation-specific bits */
- size = threads_table.size;
+ threads_impl_thread_new(t);
- log_println("threads table ==========");
+ /* add the thread to the threads-list */
- log_println("size: %d", size);
- log_println("used: %d", threads_table.used);
- log_println("daemons: %d", threads_table.daemons);
+ list_add_last_unsynced(list_threads, t);
- for (i = 0; i < size; i++) {
- index = threads_table.table[i].next;
+ /* unlock the threads-lists */
- if (threads_table.table[i].thread != NULL)
- log_println("%4d: thread=0x%08x, next=%d", i,
- threads_table.table[i].thread->tid, (int) index);
- else
- log_println("%4d: free, next=%d", i, (int) index);
- }
+ threads_list_unlock();
- log_println("end of threads table ==========");
+ return t;
}
-#endif
-/* threads_thread_new **********************************************************
+/* threads_thread_free *********************************************************
- Allocates and initializes an internal thread data-structure.
+ Frees an internal thread data-structure by removing it from the
+ threads-list and adding it to the free-list.
+
+ NOTE: The data-structure is NOT freed, the pointer keeps valid!
*******************************************************************************/
-threadobject *threads_thread_new(void)
+void threads_thread_free(threadobject *t)
{
- threadobject *t;
+ s4 index;
- /* allocate internal thread data-structure */
+ /* lock the threads-lists */
-#if defined(ENABLE_GC_BOEHM)
- t = GCNEW_UNCOLLECTABLE(threadobject, 1);
-#else
- t = NEW(threadobject);
-#endif
+ threads_list_lock();
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- size_threadobject += sizeof(threadobject);
-#endif
+ /* cleanup the implementation-specific bits */
- /* initialize thread data structure */
+ threads_impl_thread_free(t);
- t->index = 0;
- t->interrupted = false;
- t->signaled = false;
- t->sleeping = false;
+ /* remove the thread from the threads-list */
- threads_impl_thread_new(t);
+ list_remove_unsynced(list_threads, t);
- return t;
-}
+ /* Clear memory, but keep the thread-index. */
+ /* ATTENTION: Do this after list_remove, otherwise the linkage
+ pointers are invalid. */
+ index = t->index;
-/* threads_thread_free *********************************************************
+ MZERO(t, threadobject, 1);
- Frees an internal thread data-structure.
+ t->index = index;
-*******************************************************************************/
+ /* add the thread to the free list */
-void threads_thread_free(threadobject *t)
-{
- /* cleanup the implementation-specific bits */
-
- threads_impl_thread_free(t);
+ list_add_first_unsynced(list_threads_free, t);
-#if defined(ENABLE_GC_BOEHM)
- GCFREE(t);
-#else
- FREE(t, threadobject);
-#endif
+ /* unlock the threads-lists */
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- size_threadobject -= sizeof(threadobject);
-#endif
+ threads_list_unlock();
}
java_lang_Thread *object;
utf *name;
+ assert(t->state != THREAD_STATE_NEW);
+
/* the thread may be currently in initalization, don't print it */
object = t->object;
(ptrint) t, (ptrint) t->tid, (ptrint) t->tid);
#endif
+ printf(" index=%d", t->index);
+
/* print thread state */
switch (t->state) {
}
+/* threads_thread_state_runnable ***********************************************
+
+ Set the current state of the given thread to THREAD_STATE_RUNNABLE.
+
+*******************************************************************************/
+
+void threads_thread_state_runnable(threadobject *t)
+{
+ /* set the state inside the lock */
+
+ threads_list_lock();
+
+ t->state = THREAD_STATE_RUNNABLE;
+
+ threads_list_unlock();
+}
+
+
+/* threads_thread_state_waiting ************************************************
+
+ Set the current state of the given thread to THREAD_STATE_WAITING.
+
+*******************************************************************************/
+
+void threads_thread_state_waiting(threadobject *t)
+{
+ /* set the state in the lock */
+
+ threads_list_lock();
+
+ t->state = THREAD_STATE_WAITING;
+
+ threads_list_unlock();
+}
+
+
+/* threads_thread_state_timed_waiting ******************************************
+
+ Set the current state of the given thread to
+ THREAD_STATE_TIMED_WAITING.
+
+*******************************************************************************/
+
+void threads_thread_state_timed_waiting(threadobject *t)
+{
+ /* set the state in the lock */
+
+ threads_list_lock();
+
+ t->state = THREAD_STATE_TIMED_WAITING;
+
+ threads_list_unlock();
+}
+
+
+/* threads_thread_state_terminated *********************************************
+
+ Set the current state of the given thread to
+ THREAD_STATE_TERMINATED.
+
+*******************************************************************************/
+
+void threads_thread_state_terminated(threadobject *t)
+{
+ /* set the state in the lock */
+
+ threads_list_lock();
+
+ t->state = THREAD_STATE_TERMINATED;
+
+ threads_list_unlock();
+}
+
+
/* threads_thread_get_state ****************************************************
Returns the current state of the given thread.
*******************************************************************************/
-utf *threads_thread_get_state(threadobject *thread)
+utf *threads_thread_get_state(threadobject *t)
{
utf *u;
- switch (thread->state) {
+ switch (t->state) {
case THREAD_STATE_NEW:
u = utf_new_char("NEW");
break;
u = utf_new_char("TERMINATED");
break;
default:
- vm_abort("threads_get_state: unknown thread state %d", thread->state);
+ vm_abort("threads_get_state: unknown thread state %d", t->state);
/* keep compiler happy */
/* XXX we should stop the world here */
- /* lock the threads table */
+ /* lock the threads lists */
- threads_table_lock();
+ threads_list_lock();
printf("Full thread dump CACAO "VERSION":\n");
/* iterate over all started threads */
- for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
+ for (t = threads_list_first(); t != NULL; t = threads_list_next(t)) {
/* print thread info */
printf("\n");
threads_thread_print_stacktrace(t);
}
- /* unlock the threads table */
+ /* unlock the threads lists */
- threads_table_unlock();
+ threads_list_unlock();
}