* src/threads/threads-common.c (threads_table_get): Made static and
authortwisti <none@none>
Mon, 7 May 2007 11:35:30 +0000 (11:35 +0000)
committertwisti <none@none>
Mon, 7 May 2007 11:35:30 +0000 (11:35 +0000)
removed table lock.
(threads_dump): Lock threads table.

* src/threads/threads-common.h (threads_table_get): Removed.

* src/threads/native/threads.c (threads_cast_stopworld): Lock threads
table.
(threads_cast_startworld): Likewise.

src/threads/native/threads.c
src/threads/threads-common.c
src/threads/threads-common.h

index ec41bb57ce3b46966949d31357c92e0e7cde8fd9..42b3365ccc2a9ccd4df91691a51925f981456e84 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads.c 7864 2007-05-03 21:17:26Z twisti $
+   $Id: threads.c 7875 2007-05-07 11:35:30Z twisti $
 
 */
 
@@ -474,7 +474,10 @@ void threads_cast_stopworld(void)
 #endif
 
        lock_stopworld(STOPWORLD_FROM_CLASS_NUMBERING);
-/*     pthread_mutex_lock(&threadlistlock); */
+
+       /* lock the threads table */
+
+       threads_table_lock();
 
 #if defined(__DARWIN__)
        threads_cast_darwinstop();
@@ -494,12 +497,17 @@ void threads_cast_stopworld(void)
                threads_sem_wait(&suspend_ack);
 #endif
 
-/*     pthread_mutex_unlock(&threadlistlock); */
+       /* unlock the threads table */
+
+       threads_table_unlock();
 }
 
 void threads_cast_startworld(void)
 {
-/*     pthread_mutex_lock(&threadlistlock); */
+       /* lock the threads table */
+
+       threads_table_lock();
+
 #if defined(__DARWIN__)
        threads_cast_darwinresume();
 #elif defined(__MIPS__)
@@ -510,7 +518,11 @@ void threads_cast_startworld(void)
 #else
        threads_cast_sendsignals(GC_signum2());
 #endif
-/*     pthread_mutex_unlock(&threadlistlock); */
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
+
        unlock_stopworld();
 }
 
index a23a034d198fd275880907c2aea5646615eefd00..acd89a949414ee76e2fafbae003b6357f79fe2c3 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.c 7853 2007-05-02 20:40:11Z twisti $
+   $Id: threads-common.c 7875 2007-05-07 11:35:30Z twisti $
 
 */
 
@@ -372,26 +372,20 @@ void threads_table_remove(threadobject *thread)
          free-list header where the thread pointer is always NULL and
          this is thre expected behavior.
 
+   NOTE: This function does not lock the table.
+
 *******************************************************************************/
 
-threadobject *threads_table_get(s4 index)
+static threadobject *threads_table_get(s4 index)
 {
        threadobject *thread;
 
-       /* lock the threads table */
-
-       threads_table_lock();
-
        /* get the requested entry */
 
        assert((index >= 0) && (index < threads_table.size));
 
        thread = threads_table.table[index].thread;
 
-       /* unlock the threads table */
-
-       threads_table_unlock();
-
        return thread;
 }
 
@@ -441,6 +435,8 @@ s4 threads_table_get_non_daemons(void)
    NOTE: This is always the entry with index 1 and must be the main
          thread.
 
+   NOTE: This function does not lock the table.
+
 *******************************************************************************/
 
 threadobject *threads_table_first(void)
@@ -460,6 +456,8 @@ threadobject *threads_table_first(void)
    Return the next thread of the threads table relative to the passed
    one.
 
+   NOTE: This function does not lock the table.
+
 *******************************************************************************/
 
 threadobject *threads_table_next(threadobject *thread)
@@ -763,21 +761,24 @@ bool threads_thread_is_alive(threadobject *thread)
 
 void threads_dump(void)
 {
-       threadobject     *thread;
+       threadobject     *t;
        java_lang_Thread *object;
        utf              *name;
 
        /* XXX we should stop the world here */
 
+       /* lock the threads table */
+
+       threads_table_lock();
+
        printf("Full thread dump CACAO "VERSION":\n");
 
        /* iterate over all started threads */
 
-       for (thread = threads_table_first(); thread != NULL;
-                thread = threads_table_next(thread)) {
+       for (t = threads_table_first(); t != NULL; t = threads_table_next(t)) {
                /* get thread object */
 
-               object = thread->object;
+               object = t->object;
 
                /* the thread may be currently in initalization, don't print it */
 
@@ -800,16 +801,14 @@ void threads_dump(void)
                        printf(" prio=%d", object->priority);
 
 #if SIZEOF_VOID_P == 8
-                       printf(" tid=0x%016lx (%ld)",
-                                  (ptrint) thread->tid, (ptrint) thread->tid);
+                       printf(" tid=0x%016lx (%ld)", (ptrint) t->tid, (ptrint) t->tid);
 #else
-                       printf(" tid=0x%08x (%d)",
-                                  (ptrint) thread->tid, (ptrint) thread->tid);
+                       printf(" tid=0x%08x (%d)", (ptrint) t->tid, (ptrint) t->tid);
 #endif
 
                        /* print thread state */
 
-                       switch (thread->state) {
+                       switch (t->state) {
                        case THREAD_STATE_NEW:
                                printf(" new");
                                break;
@@ -829,17 +828,20 @@ void threads_dump(void)
                                printf(" terminated");
                                break;
                        default:
-                               vm_abort("threads_dump: unknown thread state %d",
-                                                thread->state);
+                               vm_abort("threads_dump: unknown thread state %d", t->state);
                        }
 
                        printf("\n");
 
                        /* print trace of thread */
 
-                       threads_thread_print_stacktrace(thread);
+                       threads_thread_print_stacktrace(t);
                }
        }
+
+       /* unlock the threads table */
+
+       threads_table_unlock();
 }
 
 
index e3c440641b27caeb8c1e7803796b74e736dc1615..4e515f22ea2bcc98762d16a2c861650171e24a99 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: threads-common.h 7853 2007-05-02 20:40:11Z twisti $
+   $Id: threads-common.h 7875 2007-05-07 11:35:30Z twisti $
 
 */
 
@@ -107,7 +107,6 @@ void          threads_preinit(void);
 
 s4            threads_table_add(threadobject *thread);
 void          threads_table_remove(threadobject *thread);
-threadobject *threads_table_get(s4 index);
 s4            threads_table_get_threads(void);
 s4            threads_table_get_non_daemons(void);
 threadobject *threads_table_first(void);