You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2007/10/09 19:06:38 UTC

svn commit: r583223 [1/2] - in /harmony/enhanced/drlvm/trunk/vm: gc_cc/src/ gc_gen/src/common/ include/open/ tests/unit/thread/ tests/unit/thread/utils/ thread/src/ thread/src/linux/ thread/src/win/ vmcore/include/ vmcore/src/class_support/ vmcore/src/...

Author: wjwashburn
Date: Tue Oct  9 10:06:34 2007
New Revision: 583223

URL: http://svn.apache.org/viewvc?rev=583223&view=rev
Log:
Harmony-4830:  This is the last patch for the Thread Lifecycle project.  THis patch deallocates C structs once the java thread dies.  Since there is a dependency on the next project (Thread State Transition), some of the deallocation code is commented out.  It will be un-commented once Thread State Transition is committed



Removed:
    harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h
Modified:
    harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
    harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
    harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
    harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
    harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMMemoryManager.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ipf.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_generic.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_basic.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_monitors.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_java_suspend.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_manager.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_instr.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_others.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/thread_ti_timing.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32_em64t/nt_exception_filter_common.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp Tue Oct  9 10:06:34 2007
@@ -293,6 +293,7 @@
         disable_assert_dialogs();
     }
 
+    vm_gc_lock_init();
     init_mem();
     init_slots();
     init_select_gc();

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_common.cpp Tue Oct  9 10:06:34 2007
@@ -327,6 +327,7 @@
   INFO2("gc.process", "GC: stop the threads and enumerate rootset ...\n");
   gc_clear_rootset(gc);
   gc_reset_rootset(gc);
+  int disable_count = hythread_reset_suspend_disable();
   vm_enumerate_root_set_all_threads();
   gc_copy_interior_pointer_table_to_rootset();
   gc_set_rootset(gc);
@@ -397,6 +398,8 @@
   
   vm_reclaim_native_objs();
   vm_resume_threads_after();
+  assert(hythread_is_suspend_enabled());
+  hythread_set_suspend_disable(disable_count);
   INFO2("gc.process", "GC: GC end\n");
   return;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_for_vm.cpp Tue Oct  9 10:06:34 2007
@@ -58,6 +58,8 @@
   INFO2("gc.process", "GC: call GC init...\n");
   assert(p_global_gc == NULL);
 
+  vm_gc_lock_init();
+
 #ifndef USE_MARK_SWEEP_GC
   unsigned int gc_struct_size = sizeof(GC_Gen);
 #else
@@ -205,7 +207,9 @@
 void gc_force_gc() 
 {
   vm_gc_lock_enum();
+
   gc_reclaim_heap(p_global_gc, GC_CAUSE_RUNTIME_FORCE_GC);  
+
   vm_gc_unlock_enum();
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/gc_gen/src/common/gc_platform.h Tue Oct  9 10:06:34 2007
@@ -106,7 +106,7 @@
 { 
   hythread_t ret_thread = (hythread_t)STD_CALLOC(1, hythread_get_struct_size());;
   assert(ret_thread);
-  return (int)hythread_create_ex(ret_thread, get_gc_thread_group(), 0, 0,
+  return (int)hythread_create_ex(ret_thread, get_gc_thread_group(), 0, 0, NULL,
                     (hythread_entrypoint_t)func, data);
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Tue Oct  9 10:06:34 2007
@@ -170,10 +170,10 @@
 
 typedef struct HyThread *hythread_iterator_t;
 typedef struct HyThreadLibrary *hythread_library_t;
-
 typedef U_32  hythread_thin_monitor_t;
-
 typedef void (*hythread_event_callback_proc)(void);
+typedef int (HYTHREAD_PROC *hythread_wrapper_t)(void*);
+typedef struct hythread_start_proc_data * hythread_start_proc_data_t;
 
 /**
  * Native thread control structure.
@@ -337,7 +337,12 @@
     /**
      * Flag illustrates that java thread status
      */
-    int java_status;
+    char java_status;
+
+    /**
+     * Release indicator
+     */
+    char need_to_free;
 
     /**
      * Size of thread's stack, set on creation
@@ -358,6 +363,38 @@
 
 } HyThread;
 
+/**
+ * Start procedure data structure.
+ */
+typedef struct hythread_start_proc_data {
+
+    /**
+     * A new thread
+     */
+    hythread_t thread;
+
+    /**
+     * Thread group of a new thread
+     */
+    hythread_group_t group;
+
+    /**
+     * Thread start procedure
+     */
+    hythread_entrypoint_t proc;
+
+    /**
+     * Start procedure arguments
+     */
+    void *proc_args;
+} hythread_start_proc_data;
+
+typedef struct tm_props {
+    int use_soft_unreservation;
+} tm_props;
+
+extern VMIMPORT tm_props *tm_properties;
+
 //@}
 /** @name Thread Manager initialization / shutdown
  */
@@ -370,6 +407,8 @@
 IDATA VMCALL hythread_global_unlock();
 void VMCALL hythread_init(hythread_library_t lib);
 void VMCALL hythread_shutdown();
+void VMCALL hythread_shutdowning();
+int VMCALL hythread_lib_state();
 IDATA VMCALL hythread_lib_create(hythread_library_t * lib);
 void VMCALL hythread_lib_destroy(hythread_library_t lib);
 hythread_group_t VMCALL get_java_thread_group(void);
@@ -379,8 +418,11 @@
  */
 //@{
 
-IDATA VMCALL hythread_create_ex(hythread_t new_thread, hythread_group_t group, UDATA stacksize, UDATA priority, hythread_entrypoint_t func, void *data);
+IDATA VMCALL hythread_create_ex(hythread_t new_thread, hythread_group_t group, UDATA stacksize, UDATA priority, hythread_wrapper_t wrapper, hythread_entrypoint_t func, void *data);
 IDATA VMCALL hythread_attach_ex(hythread_t new_handle, hythread_library_t lib, hythread_group_t group);
+void VMCALL hythread_detach_ex(hythread_t thread);
+IDATA VMCALL hythread_set_to_group(hythread_t thread, hythread_group_t group);
+void VMCALL hythread_set_self(hythread_t thread);
 UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread);
 IDATA VMCALL hythread_join(hythread_t t);
 IDATA VMCALL hythread_join_timed(hythread_t t, I_64 millis, IDATA nanos);
@@ -389,6 +431,7 @@
 IDATA VMCALL hythread_get_id(hythread_t t);
 hythread_t VMCALL hythread_get_thread(IDATA id);
 IDATA VMCALL hythread_struct_init(hythread_t new_thread);
+IDATA VMCALL hythread_struct_release(hythread_t thread);
 IDATA VMCALL hythread_cancel_all(hythread_group_t group);
 IDATA hythread_group_create(hythread_group_t *group);
 IDATA VMCALL hythread_group_release(hythread_group_t group);
@@ -603,6 +646,8 @@
     thread = tm_self_tls;
     ((HyThread_public *)thread)->disable_count++;
 
+    //apr_memory_rw_barrier();
+
     if (((HyThread_public *)thread)->request && 
 	((HyThread_public *)thread)->disable_count == 1) {
         // enter to safe point if suspend request was set
@@ -699,6 +744,10 @@
 #define TM_STATUS_WITHOUT_JAVA  0   // native thread cannot has associated java thread
 #define TM_STATUS_ALLOCATED     1   // associated java thread is allocated
 #define TM_STATUS_INITIALIZED   2   // associated java thread is initialized
+
+#define TM_LIBRARY_STATUS_NOT_INITIALIZED   0
+#define TM_LIBRARY_STATUS_INITIALIZED       1
+#define TM_LIBRARY_STATUS_SHUTDOWN          2
 
 #if defined(__cplusplus)
 }

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h Tue Oct  9 10:06:34 2007
@@ -51,14 +51,16 @@
 //@{
 
 typedef struct JVMTIThread *jvmti_thread_t;
-typedef struct jthread_thread_attr jthread_threadattr_t;
+typedef struct jthread_start_proc_data * jthread_start_proc_data_t;
 typedef struct VM_thread * vm_thread_t;
 
-VMEXPORT jlong jthread_thread_init(JNIEnv* env, jthread java_thread, jobject weak_ref, hythread_t old_thread);
-VMEXPORT IDATA jthread_create(JNIEnv * jni_env, jthread thread, jthread_threadattr_t *attrs);
-VMEXPORT IDATA jthread_create_with_function(JNIEnv * jni_env, jthread thread, jthread_threadattr_t *attrs);
+VMEXPORT jlong jthread_thread_init(JNIEnv *jni_env, jthread java_thread, jobject weak_ref, hythread_t dead_thread);
+VMEXPORT IDATA jthread_create(JNIEnv * jni_env, jthread thread, jthread_start_proc_data_t attrs);
+VMEXPORT IDATA jthread_create_with_function(JNIEnv * jni_env, jthread thread, jthread_start_proc_data_t attrs);
 VMEXPORT IDATA jthread_attach(JNIEnv * jni_env, jthread thread, jboolean daemon);
 VMEXPORT IDATA jthread_detach(jthread thread);
+VMEXPORT IDATA jthread_java_detach(jthread thread);
+VMEXPORT IDATA jthread_vm_detach(vm_thread_t vm_thread);
 VMEXPORT IDATA jthread_yield();
 VMEXPORT IDATA jthread_stop(jthread thread);
 VMEXPORT IDATA jthread_exception_stop(jthread thread, jobject throwable);

Modified: harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/vm_gc.h Tue Oct  9 10:06:34 2007
@@ -51,6 +51,10 @@
  */
 VMEXPORT void *vm_get_gc_thread_local();
 
+/**
+ * Initializes the lock that guards all GC-related operations in the VM.
+ */
+VMEXPORT void vm_gc_lock_init();
 
 /**
  * Acquire the lock that guards all GC-related operations in the VM.
@@ -59,7 +63,6 @@
  * enumeration.
  */
 VMEXPORT void vm_gc_lock_enum();
-
 
 /**
  * Release the system-wide lock acquired by <code>vm_gc_lock_enum()</code>.

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_java_basic.c Tue Oct  9 10:06:34 2007
@@ -28,15 +28,27 @@
 int HYTHREAD_PROC run_for_test_jthread_attach(void *args){
     tested_thread_sturct_t * tts;
     hythread_t native_thread;
+    vm_thread_t vm_thread;
     JNIEnv * jni_env;
     IDATA status;
 
+    // grab hythread global lock
+    hythread_global_lock();
+
     tts = (tested_thread_sturct_t *) args;
     native_thread = hythread_self();
     if (!native_thread) {
-        status = hythread_attach(&native_thread);
+        native_thread = (hythread_t)calloc(1, sizeof(struct VM_thread));
+        if (native_thread == NULL) {
+            hythread_global_unlock();
+            tf_assert_same(native_thread, NULL);
+            return 0;
+        }
+        native_thread->java_status = TM_STATUS_ALLOCATED;
+        status = hythread_attach_ex(native_thread, NULL, NULL);
         if (status != JNI_OK) {
             tts->phase = TT_PHASE_ERROR;
+            hythread_global_unlock();
             return 0;
         }
     }
@@ -44,15 +56,23 @@
     status = vm_attach(GLOBAL_VM, &jni_env);
     if (status != JNI_OK) {
         tts->phase = TT_PHASE_ERROR;
+        hythread_global_unlock();
         return 0;
     }
 
     status = jthread_attach(jni_env, tts->java_thread, JNI_FALSE);
     tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_ATTACHED : TT_PHASE_ERROR);
+
+    // release hythread global lock
+    hythread_global_unlock();
+
     tested_thread_started(tts);
     tested_thread_wait_for_stop_request(tts);
-    status = jthread_detach(tts->java_thread);
+
+    vm_thread = jthread_self_vm_thread();
+    status = jthread_detach(vm_thread->java_thread);
     tts->phase = (status == TM_ERROR_NONE ? TT_PHASE_DEAD : TT_PHASE_ERROR);
+
     tested_thread_ended(tts);
     return 0;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c Tue Oct  9 10:06:34 2007
@@ -43,13 +43,13 @@
     
     hythread_group_create((hythread_group_t *)&args[0]); 
     
-    args[1] = calloc(1, sizeof(jthread_threadattr_t));
-    ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
-    ((jthread_threadattr_t *)args[1])->priority  = 1;
+    args[1] = calloc(1, sizeof(struct jthread_start_proc_data));
+    ((jthread_start_proc_data_t)args[1])->stacksize = 1024000;
+    ((jthread_start_proc_data_t)args[1])->priority  = 1;
     
     thread = (hythread_t)calloc(1, hythread_get_struct_size());
     assert(thread);
-    res = hythread_create_ex(thread, args[0], 1024000, 1,
+    res = hythread_create_ex(thread, args[0], 1024000, 1, NULL,
         (hythread_entrypoint_t)start_proc, args);
     tf_assert(res == TM_ERROR_NONE && "thread creation failed");
 
@@ -107,7 +107,7 @@
         IDATA status;
         thread = (hythread_t)calloc(1, hythread_get_struct_size());
         assert(thread);
-        status = hythread_create_ex(thread, group, 0, 0,
+        status = hythread_create_ex(thread, group, 0, 0, NULL,
             (hythread_entrypoint_t)start_proc_empty, NULL);
         tf_assert_same(status, TM_ERROR_NONE);
     }
@@ -193,13 +193,13 @@
     
         args[0] = group; 
         
-        args[1] = calloc(1, sizeof(jthread_threadattr_t));
-        ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
-        ((jthread_threadattr_t *)args[1])->priority  = 1;
+        args[1] = calloc(1, sizeof(struct jthread_start_proc_data));
+        ((jthread_start_proc_data_t)args[1])->stacksize = 1024000;
+        ((jthread_start_proc_data_t)args[1])->priority  = 1;
         
         thread = (hythread_t)calloc(1, hythread_get_struct_size());
         assert(thread);
-        res = hythread_create_ex(thread, group, 1024000, 1,
+        res = hythread_create_ex(thread, group, 1024000, 1, NULL,
             (hythread_entrypoint_t)start_proc, args);
         tf_assert(res == TM_ERROR_NONE && "thread creation failed");
         res = hythread_join(thread);
@@ -222,7 +222,7 @@
 
 int start_proc(void *args) {
     void** attrs = (void **)args; 
-    tf_assert_same(hythread_get_priority(hythread_self()), ((jthread_threadattr_t *)attrs[1])->priority);
+    tf_assert_same(hythread_get_priority(hythread_self()), ((jthread_start_proc_data_t)attrs[1])->priority);
     tf_assert_same(((HyThread_public*)hythread_self())->group, attrs[0]);
     return 0;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_thin_monitor.c Tue Oct  9 10:06:34 2007
@@ -151,7 +151,7 @@
     tf_assert_same(status, TM_ERROR_NONE);
     args[1] = 0;
     hythread_suspend_enable();    
-    status = hythread_create_ex(thread, NULL, 0, 0,
+    status = hythread_create_ex(thread, NULL, 0, 0, NULL,
         (hythread_entrypoint_t)start_proc, args);
     tf_assert_same(status, TM_ERROR_NONE);
     for(i = 0; i < 100000; i++) {

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_ti_instrum.c Tue Oct  9 10:06:34 2007
@@ -20,7 +20,6 @@
 #include "thread_unit_test_utils.h"
 #include <open/jthread.h>
 #include <open/ti_thread.h>
-#include <open/thread_externals.h>
 
 hysem_t mon_enter;
 

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.c Tue Oct  9 10:06:34 2007
@@ -23,7 +23,6 @@
 #include "open/hythread.h"
 #include "open/hythread_ext.h"
 #include "open/ti_thread.h"
-#include "open/thread_externals.h"
 #include "thread_manager.h"
 
 /*
@@ -268,7 +267,7 @@
         tf_assert_v(tts->native_thread != NULL);
         tts->native_thread->java_status = TM_STATUS_ALLOCATED;
         status = hythread_create_ex(tts->native_thread,
-            NULL, 0, 0, run_method_param, tts);
+            NULL, 0, 0, NULL, run_method_param, tts);
         tf_assert_v(status == TM_ERROR_NONE);
         tested_thread_wait_started(tts);
     }

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/utils/thread_unit_test_utils.h Tue Oct  9 10:06:34 2007
@@ -76,7 +76,7 @@
     hysem_t ended;
     int phase;
     jint peak_count;
-    jthread_threadattr_t attrs;
+    struct jthread_start_proc_data attrs;
     jclass excn;
 } tested_thread_sturct_t;
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Tue Oct  9 10:06:34 2007
@@ -3,6 +3,7 @@
 EXPORTS
  
 hythread_detach
+hythread_detach_ex
 hythread_uses_fast_tls
 hythread_tls_alloc
 hythread_sleep_interruptable
@@ -18,6 +19,7 @@
 hythread_monitor_init_with_name
 hythread_monitor_try_enter
 hythread_self
+hythread_set_self
 hythread_self_slow
 hythread_tls_free
 hythread_yield
@@ -58,6 +60,7 @@
 hythread_group_create
 hythread_group_release
 hythread_group_get_list
+hythread_set_to_group
 hythread_is_suspend_enabled
 hythread_suspend_enable
 hythread_suspend_disable
@@ -122,6 +125,8 @@
 hythread_is_terminated
 hythread_init
 hythread_shutdown
+hythread_shutdowning
+hythread_lib_state
 hythread_lib_create
 hythread_lib_destroy
 hythread_lib_lock

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Tue Oct  9 10:06:34 2007
@@ -2,6 +2,7 @@
     global :
 get_tls_helper;
 hythread_detach;
+hythread_detach_ex;
 hythread_tls_alloc;
 hythread_sleep_interruptable;
 hythread_cancel;
@@ -16,6 +17,7 @@
 hythread_monitor_init_with_name;
 hythread_monitor_try_enter;
 hythread_self;
+hythread_set_self;
 tm_self_tls;
 hythread_tls_free;
 hythread_yield;
@@ -58,6 +60,7 @@
 hythread_group_create;
 hythread_group_release;
 hythread_group_get_list;
+hythread_set_to_group;
 hythread_is_suspend_enabled;
 hythread_suspend_enable;
 hythread_suspend_disable;
@@ -135,6 +138,8 @@
 hythread_is_alive;
 hythread_init;
 hythread_shutdown;
+hythread_shutdowning;
+hythread_lib_state;
 hythread_lib_create;
 hythread_lib_destroy;
 hythread_lib_lock;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Tue Oct  9 10:06:34 2007
@@ -47,7 +47,7 @@
  *         of insufficient memory, system error otherwise.
  */
 int os_thread_create(/* out */osthread_t* phandle, UDATA stacksize, UDATA priority,
-        int (VMAPICALL *func)(void*), void *data)
+        hythread_wrapper_t func, void *data)
 {
     pthread_t thread;
     pthread_attr_t attr;

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c Tue Oct  9 10:06:34 2007
@@ -26,7 +26,6 @@
 #include <open/hythread_ext.h>
 #include "thread_private.h"
 
-
 //global constants:
 
 // Global pointer to the threading library
@@ -40,7 +39,7 @@
 
 //Thread manager global lock
 hymutex_t TM_START_LOCK;
-static int TM_INITIALIZED = 0;
+static int hythread_library_state = TM_LIBRARY_STATUS_NOT_INITIALIZED;
 #define GLOBAL_MONITOR_NAME "global_monitor"
 hythread_monitor_t p_global_monitor;
 
@@ -131,8 +130,9 @@
     }
     assert(TM_LIBRARY == lib);
 
-    if (TM_INITIALIZED) return;
-    TM_INITIALIZED = 1;
+    if (hythread_library_state != TM_LIBRARY_STATUS_NOT_INITIALIZED)
+        return;
+    hythread_library_state = TM_LIBRARY_STATUS_INITIALIZED;
      
     apr_status = apr_initialize();
     assert(apr_status == APR_SUCCESS);
@@ -173,6 +173,24 @@
 }
 
 /**
+ * Prepares to shutdown the hythread library.
+ *
+ * @return none
+ *
+ * @see hythread_init
+ */
+void VMCALL hythread_shutdowning() {
+    hythread_library_state = TM_LIBRARY_STATUS_SHUTDOWN;
+}
+
+/**
+ * Returns hythread library state
+ */
+int VMCALL hythread_lib_state() {
+    return hythread_library_state;
+}
+
+/**
  * Shut down the threading library associated with the current thread.
  * 
  * @return none
@@ -215,38 +233,35 @@
  * The lock blocks new thread creation and thread exit operations. 
  */
 IDATA VMCALL hythread_global_lock() {
-    IDATA r = 0;
-    hythread_t self = tm_self_tls;
-    int saved_count;
+    IDATA status;
+    hythread_t self = hythread_self();
 
     // we need not care about suspension if the thread
-    // is not even tattached to hythread
-    if (self == NULL)
+    // is not even attached to hythread
+    if (self == NULL) {
         return hymutex_lock(&TM_LIBRARY->TM_LOCK);
+    }
 
-    // suspend_disable_count must be 0 on potentially
+    // disable_count must be 0 on potentially
     // blocking operation to prevent suspension deadlocks,
     // meaning that the thread is safe for suspension
-    saved_count = hythread_reset_suspend_disable();
-    r = hymutex_lock(&TM_LIBRARY->TM_LOCK);
-    if (r) return r;
+    assert(hythread_is_suspend_enabled());
+
+    status = hymutex_lock(&TM_LIBRARY->TM_LOCK);
+    assert(status == TM_ERROR_NONE);
 
     // make sure we do not get a global thread lock
     // while being requested to suspend
-    while (self->request) {
+    while (self->suspend_count) {
         // give up global thread lock before safepoint,
         // because this thread can be suspended at a safepoint
-        r = hymutex_unlock(&TM_LIBRARY->TM_LOCK);
-        if (r) return r;
+        status = hymutex_unlock(&TM_LIBRARY->TM_LOCK);
+        assert(status == TM_ERROR_NONE);
         hythread_safe_point();
-        r = hymutex_lock(&TM_LIBRARY->TM_LOCK);
-        if (r) return r;
+        status = hymutex_lock(&TM_LIBRARY->TM_LOCK);
+        assert(status == TM_ERROR_NONE);
     }
-
-    // do not use hythread_set_suspend_disable() as we do not
-    // want safe points happening under global lock
-    self->disable_count = saved_count;
-    return 0;
+    return TM_ERROR_NONE;
 }
 
 /**
@@ -254,7 +269,11 @@
  * 
  */
 IDATA VMCALL hythread_global_unlock() {
-    return hymutex_unlock(&TM_LIBRARY->TM_LOCK);;
+    IDATA status;
+    assert(!hythread_self() || hythread_is_suspend_enabled());
+    status = hymutex_unlock(&TM_LIBRARY->TM_LOCK);
+    assert(status == TM_ERROR_NONE);
+    return TM_ERROR_NONE;
 }
 
 hythread_group_t VMCALL get_java_thread_group(void) {

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Tue Oct  9 10:06:34 2007
@@ -37,17 +37,9 @@
 #include <open/hythread_ext.h>
 #include "thread_private.h"
 
-
-typedef struct {
-    hythread_t thread;
-    hythread_group_t group;
-    hythread_entrypoint_t start_proc;
-    void * start_proc_args;
-} thread_start_proc_data;
 extern hythread_group_t TM_DEFAULT_GROUP;
 extern hythread_library_t TM_LIBRARY;
-static int VMAPICALL thread_start_proc(void *arg);
-static IDATA register_to_group(hythread_t thread, hythread_group_t group);
+static int HYTHREAD_PROC hythread_wrapper_start_proc(void *arg);
 
 #define NAKED __declspec(naked)
 
@@ -64,29 +56,6 @@
 short next_free_thread_id[MAX_ID];
 int next_id = 1;
 
-/*
-IDATA add_to_fast_thread_array(hythread_t thread,int id)
-{
-	if (id>=MAX_ID)
-	{
-		if (MAX_ID<1000)
-	    {
-			MAX_ID=1000;
-			fast_thread_array=(hythread_t *)malloc(MAX_ID*sizeof(hythread_t));
-	    }
-		else
-		{
-			MAX_ID*=2;
-			fast_thread_array=(hythread_t *)realloc(fast_thread_array,MAX_ID*sizeof(hythread_t));
-		}
-		if (fast_thread_array==NULL)
-			return TM_ERROR_OUT_OF_MEMORY;
-	}
-	fast_thread_array[id]=thread;
-	return TM_ERROR_NONE;
-}*/
-static void hythread_set_self(hythread_t thread);
-
 /**
  * Creates a new thread in a given group.
  *
@@ -104,12 +73,13 @@
                                 hythread_group_t group,
                                 UDATA stacksize,
                                 UDATA priority,
+                                hythread_wrapper_t wrapper,
                                 hythread_entrypoint_t func,
                                 void *data)
 {
     int result;
     hythread_t self;
-    thread_start_proc_data * start_proc_data;
+    hythread_start_proc_data_t start_proc_data;
 
     assert(new_thread);
     hythread_struct_init(new_thread);
@@ -119,27 +89,37 @@
     new_thread->priority = priority ? priority : HYTHREAD_PRIORITY_NORMAL;
     new_thread->stacksize = stacksize ? stacksize : TM_DEFAULT_STACKSIZE;
     
-    // No need to zero allocated memory because all fields are initilized below.
-    start_proc_data =
-        (thread_start_proc_data *) malloc(sizeof(thread_start_proc_data));
-    if (start_proc_data == NULL) {
-        return TM_ERROR_OUT_OF_MEMORY;
+    if (wrapper) {
+        assert(data);
+        start_proc_data = (hythread_start_proc_data_t)data;
+    } else {
+        // No need to zero allocated memory because all fields are initilized below.
+        start_proc_data =
+            (hythread_start_proc_data_t) malloc(sizeof(hythread_start_proc_data));
+        if (start_proc_data == NULL) {
+            return TM_ERROR_OUT_OF_MEMORY;
+        }
     }
 
     // Set up thread body procedure 
     start_proc_data->thread = new_thread;
     start_proc_data->group = group == NULL ? TM_DEFAULT_GROUP : group;
-    start_proc_data->start_proc = func;
-    start_proc_data->start_proc_args = data;
+    start_proc_data->proc = func;
+    start_proc_data->proc_args = data;
+
+    // Set wrapper procedure
+    if (!wrapper) {
+        wrapper = hythread_wrapper_start_proc;
+    }
 
     // Need to make sure thread will not register itself with a thread group
     // until os_thread_create returned and initialized thread->os_handle properly.
     hythread_global_lock();
     result = os_thread_create(&new_thread->os_handle, new_thread->stacksize,
-            priority, thread_start_proc, (void *)start_proc_data);
+            priority, wrapper, (void *)start_proc_data);
     assert(/* error */ result || new_thread->os_handle /* or thread created ok */);
     hythread_global_unlock();
-   
+
     return result;
 }
 
@@ -166,11 +146,12 @@
  */
 IDATA VMCALL hythread_create(hythread_t *handle, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) {
     hythread_t thread = (hythread_t)calloc(1, hythread_get_struct_size());
+    thread->need_to_free = 1;
     assert(thread);
     if (handle) {
         *handle = thread;
     }
-    return hythread_create_ex(thread, NULL, stacksize, priority, func, data);
+    return hythread_create_ex(thread, NULL, stacksize, priority, NULL, func, data);
 }
 
 /**
@@ -186,6 +167,8 @@
                          hythread_library_t lib,
                          hythread_group_t group)
 {
+    IDATA status;
+
     assert(new_thread);
 
     hythread_struct_init(new_thread);
@@ -196,8 +179,12 @@
 
     TRACE(("TM: native attached: native: %p ", new_thread));
 
-    return register_to_group(new_thread,
+    status = hythread_set_to_group(new_thread,
         (group == NULL ? TM_DEFAULT_GROUP : group));
+    hythread_set_self(new_thread);
+    assert(new_thread == hythread_self());
+
+    return status;
 }
 
 /**
@@ -242,31 +229,44 @@
 
 /**
  * Detaches a thread from the threading library.
+ * Assumes that the thread is being detached is already attached.
+ * Frees a given thread pointer.
  * 
- * @note Assumes that the thread being detached is already attached.<br>
- * 
- * If the thread is an attached thread, then detach should only be called by the thread
- * itself. Internal resources associated with the thread are freed.
- * 
- * If the thread is already dead, this call will destroy it.
- * 
- * @param[in] thread a hythread_t representing the thread to be detached.
- * If this is NULL, the current thread is detached.
- * @return none
+ * @param[in] thread A hythread_t representing the thread to be detached.
+ *                   If this is NULL, the current thread is detached.
  */
 void VMCALL hythread_detach(hythread_t thread) {
+    hythread_detach_ex(thread);
+
+    // FIXME - uncomment after TM state transition complete
+    // release thread data
+    //if (thread->need_to_free) {
+    //    free(thread);
+    //}
+}
+
+/**
+ * Detaches a thread from the threading library.
+ * Assumes that the thread is being detached is already attached.
+ *
+ * @param[in] thread A hythread_t representing the thread to be detached.
+ *                   If this is NULL, the current thread is detached.
+ */
+void VMCALL hythread_detach_ex(hythread_t thread)
+{
     IDATA status;
 
+    // Acquire global TM lock to prevent concurrent access to thread list
+    status = hythread_global_lock();
+    assert(status == TM_ERROR_NONE);
+
     if (thread == NULL) {
         thread = hythread_self();
     }
-    
-    // Acquire global TM lock to prevent concurrent access to thread list
-    status = hythread_global_lock(NULL);
-    assert(status == TM_ERROR_NONE);
+    assert(thread);
 
-    // No actions required in case the specified thread is detached already.
-    if (thread->group != NULL) {
+    // Detach if thread is attached to group.
+    if (thread->group) {
         // The thread can be detached from the other thread in case
         // of forceful termination by hythread_cancel(), but thread
         // local storage can be zeroed only for current thread.
@@ -274,14 +274,22 @@
             hythread_set_self(NULL);
         }
         fast_thread_array[thread->thread_id] = NULL;
-        
+
         thread->prev->next = thread->next;
         thread->next->prev = thread->prev;
         thread->group->threads_count--;
         thread->group = NULL;
     }
+
+    // Send join event to those threads who called join on this thread.
+    status = hylatch_count_down(thread->join_event);
+    assert(status == TM_ERROR_NONE);
+
+    // FIXME - uncomment after TM state transition complete
+    // release thread data
+    //hythread_struct_release(thread);
     
-    hythread_global_unlock(NULL);
+    status = hythread_global_unlock();
     assert(status == TM_ERROR_NONE);
 }
 
@@ -348,7 +356,7 @@
     return thread;
 }
 
-static void hythread_set_self(hythread_t  thread) {
+void VMCALL hythread_set_self(hythread_t  thread) {
     apr_threadkey_private_set(thread, TM_THREAD_KEY);
 }
 #else 
@@ -358,7 +366,7 @@
     return hythread_self();
 }
 
-static void hythread_set_self(hythread_t thread) {
+void VMCALL hythread_set_self(hythread_t thread) {
 #ifndef _WIN64
 #   if (_MSC_VER >= 1400)
         __writefsdword(offsetof(NT_TIB, ArbitraryUserPointer), thread);
@@ -379,7 +387,7 @@
     return hythread_self();
 }
 
-static void hythread_set_self(hythread_t  thread) {
+void VMCALL hythread_set_self(hythread_t  thread) {
     tm_self_tls = thread;
 }
 #endif // defined(_WIN32) && defined(HYTHREAD_FAST_TLS)
@@ -482,8 +490,9 @@
  * @return none
  */
 void VMCALL hythread_cancel(hythread_t thread) {
+    osthread_t os_handle = thread->os_handle;
     hythread_detach(thread);
-    os_thread_cancel(thread->os_handle);
+    os_thread_cancel(os_handle);
 }
 
 /** 
@@ -519,27 +528,27 @@
 
 /*
  */
-static IDATA register_to_group(hythread_t thread, hythread_group_t group) {
+IDATA VMCALL hythread_set_to_group(hythread_t thread, hythread_group_t group) {
     IDATA status;
-    int free_slot_found = 0;
     hythread_t cur, prev;
 
     assert(thread);
     assert(group);
     
     // Acquire global TM lock to prevent concurrent access to thread list
-    status = hythread_global_lock(NULL);
-    assert(status == 0);
+    status = hythread_global_lock();
+    assert(status == TM_ERROR_NONE);
 
     assert(thread->os_handle);
 
-    hythread_set_self(thread);
-    assert(thread == tm_self_tls);
-
-    thread->state |= TM_THREAD_STATE_ALIVE | TM_THREAD_STATE_RUNNABLE;
+    hymutex_lock(&thread->mutex);
+    thread->state |= TM_THREAD_STATE_ALIVE;
+    hymutex_unlock(&thread->mutex);
     
     if (!thread->thread_id) {
-        U_32 i;
+        char free_slot_found = 0;
+
+        unsigned int i;
         for(i = 0; i < MAX_ID; i++) {
             // increase next_id to allow thread_id change 
             next_id++;
@@ -554,7 +563,8 @@
         }
 
         if (!free_slot_found) {
-            hythread_global_unlock(NULL);
+            status = hythread_global_unlock();
+            assert(status == TM_ERROR_NONE);
             return TM_ERROR_OUT_OF_MEMORY;
         }
     }
@@ -569,7 +579,11 @@
     thread->next = cur;
     thread->prev = prev;
     prev->next = cur->prev = thread;
-    return hythread_global_unlock(NULL);    
+
+    status = hythread_global_unlock();
+    assert(status == TM_ERROR_NONE);
+
+    return TM_ERROR_NONE;
 }
 
 /**
@@ -614,52 +628,127 @@
     return TM_ERROR_NONE;
 }
 
-// Wrapper around user thread start proc. Used to perform some duty jobs 
-// right after thread is started.
-//////
-static int VMAPICALL thread_start_proc(void *arg) {
+/**
+ * Releases thread structure.
+ */
+IDATA VMCALL hythread_struct_release(hythread_t thread)
+{
     IDATA status;
+
+    assert(thread);
+
+    // Eelease thread primitives
+    status = hylatch_destroy(thread->join_event);
+    assert(status == TM_ERROR_NONE);
+    status = hysem_destroy(thread->resume_event);
+    assert(status == TM_ERROR_NONE);
+    status = hymutex_destroy(&thread->mutex);
+    assert(status == TM_ERROR_NONE);
+    status = hycond_destroy(&thread->condition);
+    assert(status == TM_ERROR_NONE);
+
+    memset(thread, 0, hythread_get_struct_size());
+    return TM_ERROR_NONE;
+}
+
+/**
+ * Wrapper around user thread start proc.
+ * Used to perform some duty jobs right after thread is started
+ * and before thread is finished.
+ */
+static int HYTHREAD_PROC hythread_wrapper_start_proc(void *arg) {
+    IDATA UNUSED status;
     hythread_t thread;
-    thread_start_proc_data * start_proc_data;
+    hythread_start_proc_data start_proc_data;
     hythread_entrypoint_t start_proc;
-    hythread_group_t group;
-    void *data;
     
-    start_proc_data = (thread_start_proc_data *) arg;
-    thread = start_proc_data->thread;
-    start_proc = start_proc_data->start_proc;
-    data = start_proc_data->start_proc_args;
-    group = start_proc_data->group;
-    free(start_proc_data);
+    // store procedure arguments to local
+    start_proc_data = *(hythread_start_proc_data_t) arg;
+    free(arg);
 
-    TRACE(("TM: native thread started: native: %p tm: %p", apr_os_thread_current(), thread));
+    // get hythread global lock
+    status = hythread_global_lock();
+    assert(status == TM_ERROR_NONE);
 
-    status = register_to_group(thread, group);
-    if (status != TM_ERROR_NONE) {
-        return status;
+    // get native thread
+    thread = start_proc_data.thread;
+    start_proc = start_proc_data.proc;
+
+    TRACE(("TM: native thread started: native: %p tm: %p",
+        apr_os_thread_current(), thread));
+
+    // check hythread library state
+    if (hythread_lib_state() != TM_LIBRARY_STATUS_INITIALIZED) {
+        // set TERMINATED state
+        hymutex_lock(&thread->mutex);
+        thread->state |= TM_THREAD_STATE_TERMINATED;
+        hymutex_unlock(&thread->mutex);
+
+        // set hythread_self()
+        hythread_set_self(thread);
+        assert(thread == hythread_self());
+
+        // release thread structure data
+        hythread_detach(thread);
+
+        // zero hythread_self() because we don't do it in hythread_detach_ex()
+        hythread_set_self(NULL);
+
+        TRACE(("TM: native thread terminated due to shutdown: native: %p tm: %p",
+            apr_os_thread_current(), thread));
+
+        // release hythread global lock
+        status = hythread_global_unlock();
+        assert(status == TM_ERROR_NONE);
+
+        return 0;
     }
 
-    // Also, should it be executed under TM global lock?
+    // register to group and set ALIVE state
+    status = hythread_set_to_group(thread, start_proc_data.group);
+    assert(status == TM_ERROR_NONE);
+
+    // set hythread_self()
+    hythread_set_self(thread);
+    assert(thread == hythread_self());
+
+    // set priority
     status = hythread_set_priority(thread, thread->priority);
-    //assert(status == TM_ERROR_NONE);//now we down - fixme
+    // FIXME - cannot set priority
+    //assert(status == TM_ERROR_NONE);
+
+    // set RUNNABLE state
+    hymutex_lock(&thread->mutex);
     thread->state |= TM_THREAD_STATE_RUNNABLE;
+    hymutex_unlock(&thread->mutex);
+
+    // release hythread global lock
+    status = hythread_global_unlock();
+    assert(status == TM_ERROR_NONE);
 
     // Do actual call of the thread body supplied by the user.
-    start_proc(data);
+    start_proc(start_proc_data.proc_args);
+
+    assert(hythread_is_suspend_enabled());
 
-    // Shutdown sequence.
-    status = hythread_global_lock(NULL);
+    // get hythread global lock
+    status = hythread_global_lock();
     assert(status == TM_ERROR_NONE);
-    assert(hythread_is_suspend_enabled()); 
-    thread->state = TM_THREAD_STATE_TERMINATED | (TM_THREAD_STATE_INTERRUPTED  & thread->state);
 
+    // set TERMINATED state
+    hymutex_lock(&thread->mutex);
+    // FIXME - remove INTERRUPTED state after TM state transition complete
+    thread->state = TM_THREAD_STATE_TERMINATED
+        | (TM_THREAD_STATE_INTERRUPTED & thread->state);
+    hymutex_unlock(&thread->mutex);
+
+    // detach and free thread
     hythread_detach(thread);
-    // Send join event to those threads who called join on this thread.
-    hylatch_count_down(thread->join_event);
 
-    status = hythread_global_unlock(NULL);
-    assert(status == TM_ERROR_NONE);    
-    
+    // release hythread global lock
+    status = hythread_global_unlock();
+    assert(status == TM_ERROR_NONE);
+
     return 0;
 }
 
@@ -670,7 +759,7 @@
         monitor->recursion_count = 0;
         hythread_monitor_exit(monitor);
     }
-    hythread_detach(NULL);
+    hythread_detach_ex(NULL);
     os_thread_exit(0);
     // unreachable statement
     abort();
@@ -835,3 +924,14 @@
     return (IDATA)sizeof(HyThread);
 } // hythread_get_struct_size
 
+/**
+ * Returns OS thread ID.
+ */
+IDATA hythread_get_os_id(hythread_t thread)
+{
+#if 1 || defined(PLATFORM_POSIX)
+    return 0;
+#else
+    return (IDATA)GetThreadId(thread->os_handle);
+#endif // PLATFORM_POSIX
+} // hythread_get_os_id

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c Tue Oct  9 10:06:34 2007
@@ -40,26 +40,32 @@
  * @param[in] count the created key
  * @sa java.util.concurrent.CountDownLatch 
  */
-IDATA VMCALL hylatch_create(hylatch_t *latch, IDATA count) {
-    int r;
-    hylatch_t l;
+IDATA VMCALL hylatch_create(hylatch_t *latch_ptr, IDATA count) {
+    int res;
+    hylatch_t latch;
     
-    l = malloc(sizeof(HyLatch));
-    if (l == NULL) {
+    latch = malloc(sizeof(HyLatch));
+    if (latch == NULL) {
         return TM_ERROR_OUT_OF_MEMORY;
     }
-    r = hymutex_create(&l->mutex, TM_MUTEX_DEFAULT);
-    if (r) goto cleanup;
-    r = hycond_create(&l->condition);
-    if (r) goto cleanup;
-        
-    l->count = count;
-    *latch = l;
+    res = hymutex_create(&latch->mutex, TM_MUTEX_DEFAULT);
+    if (res) {
+        goto cleanup;
+    }
+    res = hycond_create(&latch->condition);
+    if (res) {
+        goto cleanup_mutex;
+    }
+    latch->count = count;
+    *latch_ptr = latch;
     return TM_ERROR_NONE;
 
+cleanup_mutex:
+    hymutex_destroy(&latch->mutex);
+
 cleanup:
-    free(l);
-    return r;
+    free(latch);
+    return res;
 }
 
 //wait method implementation
@@ -68,7 +74,9 @@
     IDATA status;
         
     status = hymutex_lock(&latch->mutex);
-    if (status != TM_ERROR_NONE) return status;
+    if (status != TM_ERROR_NONE) {
+        return status;
+    }
     while (latch->count) {
         status = condvar_wait_impl(&latch->condition, &latch->mutex, ms, nano, interruptable);
         //check interruption and other problems
@@ -80,9 +88,8 @@
         if (ms || nano) break;
     }
     status = hymutex_unlock(&latch->mutex);
-    if (status != TM_ERROR_NONE) return status;
 
-    return TM_ERROR_NONE;
+    return status;
 }
 
 /**
@@ -196,16 +203,16 @@
 
     return TM_ERROR_NONE;       
 }
+
 /**
  * Destroys the latch and releases the associated memory.
  * 
  * @param[in] latch the latch 
  */
 IDATA VMCALL hylatch_destroy(hylatch_t latch) {
-    hymutex_destroy(&latch->mutex);
-    hycond_destroy(&latch->condition);
-
+    IDATA status = hymutex_destroy(&latch->mutex);
+    status |= hycond_destroy(&latch->condition);
     free(latch);
-    return TM_ERROR_NONE;       
+    return status;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c Tue Oct  9 10:06:34 2007
@@ -229,8 +229,8 @@
  * @see hysem_init, hysem_wait, hysem_post
  */
 IDATA VMCALL hysem_destroy(hysem_t sem) {
-    hymutex_destroy(&sem->mutex);
-    hycond_destroy(&sem->condition);
+    IDATA status = hymutex_destroy(&sem->mutex);
+    status |= hycond_destroy(&sem->condition);
     free(sem);
-    return TM_ERROR_NONE;
+    return status;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Tue Oct  9 10:06:34 2007
@@ -24,7 +24,6 @@
 #define LOG_DOMAIN "tm.suspend"
 
 #include <open/hythread_ext.h>
-#include <open/thread_externals.h>
 #include "thread_private.h"
 #include <apr_atomic.h>
 
@@ -141,7 +140,7 @@
     } while (thread->suspend_count);
 
     // restore disable_count value
-    thread->disable_count = gc_disable_count;
+    hythread_set_suspend_disable(gc_disable_count);
 
     return;
 } // thread_safe_point_impl
@@ -366,9 +365,14 @@
     hythread_iterator_t iter;
     TRACE(("suspend all threads"));
 
+    assert(hythread_is_suspend_enabled());
+
     // try to prevent cyclic suspend dead-lock
     thread_safe_point_impl(self);
 
+    // get global lock to prevent new thread creation
+    hythread_global_lock();
+
     // send suspend requests to all threads
     TRACE(("send suspend requests"));
     iter = hythread_iterator_create(group);
@@ -400,8 +404,6 @@
     return TM_ERROR_NONE;
 }
 
-
-
 /**
  * Resumes all threads in the selected group.
  *
@@ -412,20 +414,24 @@
     hythread_t self = tm_self_tls;
     hythread_t next;
     hythread_iterator_t iter;
-    iter = hythread_iterator_create(group);
+
     TRACE(("resume all threads"));
 
-    // send suspend requests to all threads
+    // send resume requests to all threads
+    iter = hythread_iterator_create(group);
     while ((next = hythread_iterator_next(&iter)) != NULL) {
         if (next != self) {
             hythread_resume(next);
         }
     }
     hythread_iterator_release(&iter);
+
+    // release global lock which was got in hythread_suspend_all()
+    hythread_global_unlock();
+
     return TM_ERROR_NONE;
 }
 
-
 /**
  * Reset disable_count for currect thread.
  * The method begins suspension safe region.
@@ -453,6 +459,8 @@
 
     assert(count >= 0);
     self->disable_count = count;
+
+    apr_memory_rw_barrier();
 
     if (count && self->suspend_count) {
         thread_safe_point_impl(self);

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_thin_monitor.c Tue Oct  9 10:06:34 2007
@@ -22,10 +22,8 @@
 
 #undef LOG_DOMAIN
 #define LOG_DOMAIN "tm.locks"
-#define _TM_PROP_EXPORT
 
 #include <open/hythread_ext.h>
-#include <open/thread_externals.h>
 #include "thread_private.h"
 #include <apr_atomic.h>
 #include <port_atomic.h>
@@ -68,6 +66,7 @@
     lock_table->tables[((U_32)(_x_))/HY_FAT_TABLE_ENTRIES]\
                       [((U_32)(_x_))%HY_FAT_TABLE_ENTRIES]
 
+tm_props *tm_properties = NULL;
 
 /*
  * Lock table which holds the omapping between LockID and fat lock (OS fat_monitor) pointer.
@@ -156,7 +155,6 @@
     assert(!IS_RESERVED(*lockword_ptr));
     TRACE(("unreserved self"));
 }
-          
 
 /**
  * Used lockword

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_private.h Tue Oct  9 10:06:34 2007
@@ -22,7 +22,6 @@
 #include <open/types.h>
 #include <open/hythread_ext.h>
 #include <open/ti_thread.h>
-#include <open/thread_externals.h>
 #include <apr_pools.h>
 #include <apr_thread_mutex.h>
 #include <apr_thread_cond.h>
@@ -174,7 +173,7 @@
     /**
      * Latch count
      */
-    int count;
+    IDATA count;
 
     /**
      * Condition event used to signal threads which are waiting on the latch.
@@ -185,11 +184,6 @@
      * Mutex associated with the latch data.
      */
     hymutex_t mutex;  
-    /**
-      * latch sub pool
-      * will be destroyed by latch_destroy()
-     */
-    apr_pool_t *pool;       
     
 } HyLatch;
 
@@ -312,7 +306,7 @@
  * portability functions, private for thread module
  */
 int os_thread_create(osthread_t* phandle, UDATA stacksize, UDATA priority,
-        int (VMAPICALL *func)(void*), void *data);
+        hythread_wrapper_t func, void *data);
 int os_thread_set_priority(osthread_t thread, int priority);
 osthread_t os_thread_current();
 int os_thread_cancel(osthread_t);

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c Tue Oct  9 10:06:34 2007
@@ -32,7 +32,7 @@
  *         of insufficient memory, system error otherwise.
  */
 int os_thread_create(/* out */osthread_t* phandle, UDATA stacksize, UDATA priority,
-        int (VMAPICALL *func)(void*), void *data)
+        hythread_wrapper_t func, void *data)
 {
     HANDLE handle = (HANDLE)_beginthreadex(NULL, stacksize, (unsigned(__stdcall *)(void*))func, data, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions.h Tue Oct  9 10:06:34 2007
@@ -271,7 +271,7 @@
 void exn_rethrow_if_pending();
 
 void set_guard_stack();
-void remove_guard_stack();
+void remove_guard_stack(vm_thread_t vm_thread);
 void init_stack_info();
 VMEXPORT size_t get_available_stack_size();
 VMEXPORT bool check_available_stack_size(size_t required_size);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_direct.h Tue Oct  9 10:06:34 2007
@@ -26,6 +26,7 @@
 #include "jvmti.h"
 #include "open/hythread_ext.h"
 #include "vm_core_types.h"
+#include "vm_threads.h"
 
 struct TIEventThread
 {
@@ -129,7 +130,7 @@
     int classlen, unsigned char* classbytes,
     int* newclasslen, unsigned char** newclass);
 void jvmti_send_class_prepare_event(Class* clss);
-VMEXPORT void jvmti_send_thread_start_end_event(int is_start);
+VMEXPORT void jvmti_send_thread_start_end_event(vm_thread_t thread, int is_start);
 void jvmti_send_vm_death_event();
 void jvmti_send_gc_finish_event();
 void jvmti_send_gc_start_event();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/thread_manager.h Tue Oct  9 10:06:34 2007
@@ -19,7 +19,6 @@
 #define THREAD_MANAGER_HEADER
 
 #include "open/jthread.h"
-#include "open/thread_externals.h"
 #include "exceptions_type.h"
 
 #define GC_BYTES_IN_THREAD_LOCAL (20 * sizeof(void *))
@@ -229,9 +228,14 @@
 /**
  * Java thread creation attributes.
  */
-struct jthread_thread_attr
+struct jthread_start_proc_data
 {
     /**
+     * HyThread library procedure data
+     */
+    hythread_start_proc_data hy_data;
+
+    /**
      * Pointer to Java VM.
      */
     JavaVM *java_vm;
@@ -267,6 +271,50 @@
      */
     const void *arg;
 };
+
+/**
+ * Registrates current thread in VM, so it could execute Java.
+ *
+ * @param[in] java_vm    - current thread will be attached to the specified VM
+ * @param[out] p_jni_env - will point to JNI environment assocciated with the thread
+ */
+VMEXPORT jint vm_attach(JavaVM * java_vm, JNIEnv ** p_jni_env);
+
+/**
+ * Frees java related resources before thread exit.
+ */
+VMEXPORT jint vm_detach(jthread java_thread);
+
+/**
+ * Stores a pointer to TM-specific data in the <code>java.lang.Thread</code> object.
+ *
+ * A typical implementation may store a pointer within a private
+ * non-static field of Thread.
+ *
+ * @param[in] thread    - a <code>java.lang.Thread</code> object those private field
+ *                        is going to be used for data storage
+ * @param[in] data_ptr  - a pointer to data to be stored
+ */
+VMEXPORT void vm_jthread_set_tm_data(jthread thread, void *data_ptr);
+
+/**
+ * Retrieves TM-specific data from the <code>java.lang.Thread</code> object.
+ *
+ * @param[in] thread - a thread
+ *
+ * @return TM-specific data previously stored, or <code>NULL</code>,
+ *         if there are none.
+ */
+VMEXPORT hythread_t vm_jthread_get_tm_data(jthread thread);
+
+/**
+ * <code>vm_objects_are_equal<br>
+ * obj1 jobject<br>
+ * obj2 jobject</code>
+ *
+ * @return <code>int</code>
+ */
+VMEXPORT int vm_objects_are_equal(jobject obj1, jobject obj2);
 
 /**
  * Gets VM_thread from native thread

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_threads.h Tue Oct  9 10:06:34 2007
@@ -35,6 +35,7 @@
 #include "open/vm_gc.h"
 
 #include "jvmti.h"
+#include "jvmti_direct.h"
 #include "jni_direct.h"
 #include "thread_manager.h"
 #include "vm_core_types.h"
@@ -46,7 +47,7 @@
 #define tmn_suspend_enable_recursive hythread_suspend_enable
 
 typedef vm_thread_t (*vm_thread_accessor)();
-VMEXPORT extern vm_thread_accessor get_thread_ptr;
+extern VMEXPORT vm_thread_accessor get_thread_ptr;
 
 #define p_TLS_vmthread (jthread_self_vm_thread())
 
@@ -83,5 +84,45 @@
 void *vm_get_ip_from_regs(vm_thread_t vm_thread);
 void vm_reset_ip_from_regs(vm_thread_t vm_thread);
 
+/**
+ * @param[in] obj - jobject those address needs to be given
+ *
+ * @return The address of the memory chunk in the object which can be used by the
+ *         Thread Manager for synchronization purposes.
+ */
+hythread_thin_monitor_t * vm_object_get_lockword_addr(jobject obj);
+
+/**
+ * @return The size of the memory chunk in the object that can be used by
+ *         Thread Manager for synchronization purposes.
+ *
+ * The returned size must be equal for all Java objets and is constant over time.
+ * It should be possible to call this method during initialization time.
+ */
+size_t vm_object_get_lockword_size();
+
+/**
+ * Creates exception object using given class name and message and throws it
+ * using <code>jthread_throw_exception</code> method.
+ *
+ * @param[in] name     - char* name
+ * @param[in] message  - char* message
+ *
+ * @return <code>int</code>
+ */
+IDATA jthread_throw_exception(char* name, char* message);
+
+/**
+ * Throws given exception object. Desides whether current thread is unwindable
+ * and throws it, raises exception otherwise.
+ */
+IDATA jthread_throw_exception_object(jobject object);
+
+/**
+ * <code>ti</code> is enabled
+ *
+ * @return <code>int</code>
+ */
+int ti_is_enabled();
 
 #endif //!_VM_THREADS_H_

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/C_Interface.cpp Tue Oct  9 10:06:34 2007
@@ -2396,18 +2396,26 @@
     return vector_class->calculate_array_size(length);
 } // vm_vector_size
 
+static hymutex_t vm_gc_lock;
 
+void vm_gc_lock_init()
+{
+    IDATA UNUSED status = hymutex_create(&vm_gc_lock, TM_MUTEX_NESTED);
+    assert(status == TM_ERROR_NONE);
+} // vm_gc_lock_init
 
 void vm_gc_lock_enum()
 {
-    hythread_global_lock();
+    int disable_count = hythread_reset_suspend_disable();
+    IDATA UNUSED status = hymutex_lock(&vm_gc_lock);
+    assert(status == TM_ERROR_NONE);
+    hythread_set_suspend_disable(disable_count);
 } // vm_gc_lock_enum
 
-
-
 void vm_gc_unlock_enum()
 {
-     hythread_global_unlock();
+    IDATA UNUSED status = hymutex_unlock(&vm_gc_lock);
+    assert(status == TM_ERROR_NONE);
 } // vm_gc_unlock_enum
 
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp Tue Oct  9 10:06:34 2007
@@ -40,8 +40,9 @@
 bool exn_raised()
 {
     // no need to disable gc for simple null equality check
-    return ((NULL != p_TLS_vmthread->thread_exception.exc_object)
-        || (NULL != p_TLS_vmthread->thread_exception.exc_class));
+    vm_thread_t vm_thread = p_TLS_vmthread;
+    return ((NULL != vm_thread->thread_exception.exc_object)
+        || (NULL != vm_thread->thread_exception.exc_class));
 }
 
 
@@ -54,8 +55,9 @@
     // we can check heap references for equality to NULL
     // without disabling gc, because GC wouldn't change 
     // null to non-null and vice versa.
-    if ((NULL == p_TLS_vmthread->thread_exception.exc_object)
-        && (NULL == p_TLS_vmthread->thread_exception.exc_class)) {
+    vm_thread_t vm_thread = p_TLS_vmthread;
+    if ((NULL == vm_thread->thread_exception.exc_object)
+        && (NULL == vm_thread->thread_exception.exc_class)) {
         return NULL;
     }
 
@@ -63,13 +65,13 @@
     // curent thread exception
     jobject exc;
 
-    if (NULL != p_TLS_vmthread->thread_exception.exc_object) {
+    if (NULL != vm_thread->thread_exception.exc_object) {
         tmn_suspend_disable();
         exc = oh_allocate_local_handle();
-        exc->object = (ManagedObject *) p_TLS_vmthread->thread_exception.exc_object;
+        exc->object = (ManagedObject *) vm_thread->thread_exception.exc_object;
         tmn_suspend_enable();
-    } else if (NULL != p_TLS_vmthread->thread_exception.exc_class) {
-        exc = exn_create((Exception*)&(p_TLS_vmthread->thread_exception));
+    } else if (NULL != vm_thread->thread_exception.exc_class) {
+        exc = exn_create((Exception*)&(vm_thread->thread_exception));
     } else {
         DIE(("It's impossible internal error in exception handling."));
     }
@@ -80,20 +82,21 @@
     // we can check heap references for equality to NULL
     // without disabling gc, because GC wouldn't change
     // null to non-null and vice versa.
-    if ((NULL == p_TLS_vmthread->thread_exception.exc_object)
-        && (NULL == p_TLS_vmthread->thread_exception.exc_class)) {
+    vm_thread_t vm_thread = p_TLS_vmthread;
+    if ((NULL == vm_thread->thread_exception.exc_object)
+        && (NULL == vm_thread->thread_exception.exc_class)) {
         return NULL;
     }
 
     Class* result;
 
-    if (NULL != p_TLS_vmthread->thread_exception.exc_object) {
+    if (NULL != vm_thread->thread_exception.exc_object) {
         tmn_suspend_disable_recursive();
-        ManagedObject* exn = p_TLS_vmthread->thread_exception.exc_object;
+        ManagedObject* exn = vm_thread->thread_exception.exc_object;
         result = exn->vt()->clss;
         tmn_suspend_enable_recursive();
-    } else if (NULL != p_TLS_vmthread->thread_exception.exc_class) {
-        result = p_TLS_vmthread->thread_exception.exc_class;
+    } else if (NULL != vm_thread->thread_exception.exc_class) {
+        result = vm_thread->thread_exception.exc_class;
     } else {
         DIE(("It's impossible internal error in exception handling."));
     }
@@ -346,21 +349,22 @@
 
     exn_throw_for_JIT(exn, NULL, NULL, NULL, NULL);
 #else
-    if (NULL != p_TLS_vmthread->thread_exception.exc_object) {
-        ManagedObject* exn_mng_object = p_TLS_vmthread->thread_exception.exc_object;
+    vm_thread_t vm_thread = p_TLS_vmthread;
+    if (NULL != vm_thread->thread_exception.exc_object) {
+        ManagedObject* exn_mng_object = vm_thread->thread_exception.exc_object;
         clear_exception_internal();
 
         check_pop_frame(exn_mng_object);
 
         exn_throw_for_JIT(exn_mng_object, NULL, NULL, NULL, NULL);
-    } else if (NULL != p_TLS_vmthread->thread_exception.exc_class) {
-        Class * exc_class = p_TLS_vmthread->thread_exception.exc_class;
-        const char* exc_message = p_TLS_vmthread->thread_exception.exc_message;
+    } else if (NULL != vm_thread->thread_exception.exc_class) {
+        Class * exc_class = vm_thread->thread_exception.exc_class;
+        const char* exc_message = vm_thread->thread_exception.exc_message;
         jthrowable exc_cause = NULL;
 
-        if (p_TLS_vmthread->thread_exception.exc_cause){
+        if (vm_thread->thread_exception.exc_cause){
             exc_cause = oh_allocate_local_handle();
-            exc_cause->object = p_TLS_vmthread->thread_exception.exc_cause;
+            exc_cause->object = vm_thread->thread_exception.exc_cause;
         }
         clear_exception_internal();
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/gc/stop_the_world_root_set_enum.cpp Tue Oct  9 10:06:34 2007
@@ -90,9 +90,18 @@
     INFO2("threads","Start thread suspension ");
     vm_time_start_hook(&_start_time);   //thread suspension time measurement        
     
-    hythread_iterator_t  iterator;
+    hythread_iterator_t iterator;
     hythread_suspend_all(&iterator, NULL);
 
+    // no matter how counter-intuitive,
+    // gc_force_gc() expects gc_enabled_status == disabled,
+    // but, obviously, at a GC safepoint.
+    // See gc-safety (aka suspend-safety) rules explained elsewhere
+    // -salikh 2005-05-12
+    // it is convenient to have gc_enabled_status == disabled
+    // during the enumeration -salikh
+    hythread_suspend_disable();
+
     thread_suspend_time = vm_time_end_hook(&_start_time, &_end_time);
     INFO2("tm.suspend","Thread suspension time: "<< thread_suspend_time <<" mksec");
 
@@ -133,15 +142,9 @@
 void 
 vm_enumerate_root_set_all_threads()
 {
-    assert(!hythread_is_suspend_enabled());
-    // it is convenient to have gc_enabled_status == disabled
-    // during the enumeration -salikh
-
+    assert(hythread_is_suspend_enabled());
     stop_the_world_root_set_enumeration();
-    
     assert(!hythread_is_suspend_enabled());
-    // vm_gc_unlock_enum expects suspend enabled, enable it here
-
 } //vm_enumerate_root_set_all_threads
 
 
@@ -156,7 +159,8 @@
     jvmti_clean_reclaimed_object_tags();
 
     // Run through list of active threads and resume each one of them.
-    hythread_resume_all( NULL);
+    hythread_suspend_enable();
+    hythread_resume_all(NULL);
 
     // Make sure register stack is up-to-date with the potentially updated backing store
     si_reload_registers();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/finalizer_thread.cpp Tue Oct  9 10:06:34 2007
@@ -112,7 +112,7 @@
     for(unsigned int i = 0; i < fin_thread_info->thread_num; i++){
         fin_thread_info->thread_ids[i] = jthread_allocate_thread();
         status = hythread_create_ex((hythread_t)fin_thread_info->thread_ids[i],
-            NULL, 0, FINALIZER_THREAD_PRIORITY,
+            NULL, 0, FINALIZER_THREAD_PRIORITY, NULL,
             (hythread_entrypoint_t)finalizer_thread_func, args);
         assert(status == TM_ERROR_NONE);
         hysem_wait(fin_thread_info->attached_sem);
@@ -122,9 +122,7 @@
 void finalizer_shutdown(Boolean start_finalization_on_exit)
 {
     if(start_finalization_on_exit){
-        tmn_suspend_disable();
         gc_force_gc();
-        tmn_suspend_enable();
         activate_finalizer_threads(TRUE);
         tmn_suspend_disable();
         gc_finalize_on_exit();

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/ref_enqueue_thread.cpp Tue Oct  9 10:06:34 2007
@@ -67,7 +67,7 @@
     args[1] = (void*)get_system_thread_group(jni_env);
     vm_thread_t thread = jthread_allocate_thread();
     status = hythread_create_ex((hythread_t)thread, NULL, 0,
-        REF_ENQUEUE_THREAD_PRIORITY,
+        REF_ENQUEUE_THREAD_PRIORITY, NULL,
         (hythread_entrypoint_t)ref_enqueue_thread_func, args);
     assert(status == TM_ERROR_NONE);
     

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_init.cpp Tue Oct  9 10:06:34 2007
@@ -25,8 +25,8 @@
 #include "port_dso.h"
 
 #include "open/gc.h"
+#include "open/hythread_ext.h"
 #include "open/jthread.h"   // this is for jthread_self()
-#include "open/thread_externals.h"
 
 #include "init.h"
 #include "classloader.h"

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/init/vm_shutdown.cpp Tue Oct  9 10:06:34 2007
@@ -25,7 +25,6 @@
 #include "open/hythread.h"
 #include "open/jthread.h"
 #include "open/gc.h"
-#include "open/thread_externals.h"
 
 #include "jni.h"
 #include "jni_direct.h"
@@ -89,9 +88,36 @@
 }
 
 static void vm_shutdown_callback() {
+    hythread_suspend_enable();
+    set_unwindable(false);
+
+    vm_thread_t vm_thread = jthread_self_vm_thread();
+    assert(vm_thread);
+
+    jobject java_thread = vm_thread->java_thread;
+    assert(java_thread);
+
+    IDATA UNUSED status = jthread_detach(java_thread);
+    assert(status == TM_ERROR_NONE);
+
     hythread_exit(NULL);
 }
 
+static void vm_thread_cancel(vm_thread_t thread) {
+    assert(thread);
+
+    // grab hythread global lock
+    hythread_global_lock();
+
+    IDATA UNUSED status = jthread_vm_detach(thread);
+    assert(status == TM_ERROR_NONE);
+
+    hythread_cancel((hythread_t)thread);
+
+    // release hythread global lock
+    hythread_global_unlock();
+}
+
 /**
  * Stops running java threads by throwing an exception
  * up to the first native frame.
@@ -142,8 +168,9 @@
         // we should not cancel self and
         // non-java threads (i.e. vm_thread == NULL)
         if (native_thread != self && vm_thread != NULL) {
-            hythread_cancel(native_thread);
+            vm_thread_cancel(vm_thread);
             TRACE2("shutdown", "cancelling " << native_thread);
+            STD_FREE(vm_thread);
         }
     }
     hythread_iterator_release(&it);
@@ -194,7 +221,7 @@
         wait_native_ref_thread_detached();
 
     // Raise uncaught exception to current thread.
-    // It will be properly processed in jthread_detach().
+    // It will be properly processed in jthread_java_detach().
     if (uncaught_exception) {
         exn_raise_object(uncaught_exception);
     }
@@ -204,6 +231,9 @@
     // This event should be sent before Agent_OnUnload called.
     jvmti_send_vm_death_event();
 
+    // prepare thread manager to shutdown
+    hythread_shutdowning();
+
     // Stop all (except current) java threads
     // before destroying VM-wide data.
     vm_shutdown_stop_java_threads(java_vm->vm_env);
@@ -211,9 +241,12 @@
     // TODO: ups we don't stop native threads as well :-((
     // We are lucky! Currently, there are no such threads.
 
-    // Detach current thread.
+    // Detach current main thread.
     status = jthread_detach(java_thread);
-    if (status != TM_ERROR_NONE) return JNI_ERR;
+
+    // check detach status
+    if (status != TM_ERROR_NONE)
+        return JNI_ERR;
 
     // Shutdown signals
     extern void shutdown_signals();
@@ -347,7 +380,7 @@
     // Create a new thread for each VM to avoid scalability and deadlock problems.
     for (int i = 0; i < nVMs; i++) {
         threadBuf[i] = jthread_allocate_thread();
-        status = hythread_create_ex((hythread_t)threadBuf[i], NULL, 0, 0,
+        status = hythread_create_ex((hythread_t)threadBuf[i], NULL, 0, 0, NULL,
             vm_interrupt_entry_point, (void *)vmBuf[i]);
         assert(status == TM_ERROR_NONE);
     }
@@ -389,17 +422,18 @@
     assert(threadBuf);
 
     // Create a new thread for each VM to avoid scalability and deadlock problems.
+    IDATA UNUSED hy_status;
     for (int i = 0; i < nVMs; i++) {
         threadBuf[i] = jthread_allocate_thread();
-        IDATA UNUSED hy_status = hythread_create_ex((hythread_t)threadBuf[i],
-            NULL, 0, 0, vm_dump_entry_point, (void *)vmBuf[i]);
+        hy_status = hythread_create_ex((hythread_t)threadBuf[i],
+            NULL, 0, 0, NULL, vm_dump_entry_point, (void *)vmBuf[i]);
         assert(hy_status == TM_ERROR_NONE);
     }
 
     // spawn a new thread which will release resources.
-    status = hythread_create(NULL, 0, 0, 0,
+    hy_status = hythread_create(NULL, 0, 0, 0,
         vm_dump_process, (void *)threadBuf);
-    assert(status == TM_ERROR_NONE);
+    assert(hy_status == TM_ERROR_NONE);
 
 cleanup:
     STD_FREE(vmBuf);

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Tue Oct  9 10:06:34 2007
@@ -538,7 +538,7 @@
     jvmti_send_vm_init_event(vm_env);
 
     // Thread start event for the main thread should be sent after VMInit callback has finished.
-    jvmti_send_thread_start_end_event(1);
+    jvmti_send_thread_start_end_event(p_TLS_vmthread, 1);
 
     // Register created VM.
     APR_RING_INSERT_TAIL(&GLOBAL_VMS, java_vm, JavaVM_Internal, link);
@@ -1558,7 +1558,9 @@
     IDATA status;
     
     java_thread = jthread_self();
-    if (java_thread == NULL) return JNI_EDETACHED;
+    if (java_thread == NULL) {
+        return JNI_EDETACHED;
+    }
 
     status = jthread_detach(java_thread);
     

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Tue Oct  9 10:06:34 2007
@@ -2044,7 +2044,8 @@
     va_end(args);
 }
 
-void jvmti_send_thread_start_end_event(int is_start)
+void jvmti_send_thread_start_end_event(vm_thread_t vm_thread,
+                                       int is_start)
 {
     DebugUtilsTI *ti = VM_Global_State::loader_env->TI;
     if (!ti->isEnabled())
@@ -2061,7 +2062,8 @@
     if (!ti->is_single_step_enabled())
         return;
 
-    jvmti_thread_t jvmti_thread = jthread_self_jvmti();
+    jvmti_thread_t jvmti_thread = jthread_get_jvmti_thread((hythread_t)vm_thread);
+    assert(jvmti_thread);
     if (is_start)
     {
         // Init single step state for the thread
@@ -2349,7 +2351,7 @@
     // create TI event thread
     JNIEnv *jni_env = p_TLS_vmthread->jni_env;
     ti->event_thread = jthread_allocate_thread();
-    IDATA status = hythread_create_ex((hythread_t)ti->event_thread, NULL, 0, 0,
+    IDATA status = hythread_create_ex((hythread_t)ti->event_thread, NULL, 0, 0, NULL,
         jvmti_event_thread_function, jni_env);
     if( status != TM_ERROR_NONE ) {
         DIE("jvmti_create_event_thread: creating thread is failed!");

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_heap.cpp Tue Oct  9 10:06:34 2007
@@ -165,15 +165,7 @@
 
     CHECK_EVERYTHING();
 
-    // no matter how counter-intuitive,
-    // gc_force_gc() expects suspend_enabled_status == disabled,
-    // but, obviously, at a GC safepoint.
-    // for more details, see
-    // * "SAFE SUSPENSION" section of Developers' Guide
-    // * "THREAD SUSPENSION" section of Thread Manager documentation
-    hythread_suspend_disable();
     gc_force_gc();
-    hythread_suspend_enable();
 
     return JVMTI_ERROR_NONE;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_thread.cpp Tue Oct  9 10:06:34 2007
@@ -695,7 +695,7 @@
     jni_env = jthread_get_JNI_env(jthread_self());
 
     // Run new thread
-    jthread_threadattr_t attrs = {0};
+    jthread_start_proc_data attrs = {0};
     attrs.priority = priority; 
     attrs.daemon = JNI_TRUE;
     attrs.jvmti_env = env;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Thread.java Tue Oct  9 10:06:34 2007
@@ -291,10 +291,9 @@
         
         ThreadWeakRef oldRef = ThreadWeakRef.poll();
         ThreadWeakRef newRef = new ThreadWeakRef(this);
-        
+
         long oldPointer = (oldRef == null) ? 0 : oldRef.getNativeAddr();
         long newPointer = VMThreadManager.init(this, newRef, oldPointer);
-
         if (newPointer == 0) {
             throw new OutOfMemoryError("Failed to create new thread");
         }
@@ -670,13 +669,6 @@
     public void run() {
         if (target != null) {
             target.run();
-        }
-    }
-
-    void setAlive(boolean alive) {
-        synchronized (lock) {
-            this.isAlive = true;
-            lock.notifyAll();
         }
     }
 

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMMemoryManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMMemoryManager.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMMemoryManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMMemoryManager.cpp Tue Oct  9 10:06:34 2007
@@ -129,13 +129,6 @@
   (JNIEnv *, jclass)
 {
     assert(hythread_is_suspend_enabled());
-    // no matter how counter-intuitive,
-    // gc_force_gc() expects gc_enabled_status == disabled,
-    // but, obviously, at a GC safepoint.
-    // See gc-safety (aka suspend-safety) rules explained elsewhere
-    // -salikh 2005-05-12
-    tmn_suspend_disable();
     gc_force_gc();      
-    tmn_suspend_enable();
     return;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_lang_VMThreadManager.cpp Tue Oct  9 10:06:34 2007
@@ -27,9 +27,9 @@
 #include "open/hythread_ext.h"
 #include "open/jthread.h"
 #include "open/ti_thread.h"
-#include "open/thread_externals.h"
 #include "jni_utils.h"
 #include "thread_manager.h"
+#include "vm_threads.h"
 
 /*
  * Class:     java_lang_VMThreadManager
@@ -160,7 +160,7 @@
 JNIEXPORT jint JNICALL Java_java_lang_VMThreadManager_start
   (JNIEnv *jenv, jclass clazz, jobject thread, jlong stackSize, jboolean daemon, jint priority)
 {
-    jthread_threadattr_t attrs = {0};
+    jthread_start_proc_data attrs = {0};
 
     attrs.daemon = daemon;
     attrs.priority = priority;

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_em64t.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_em64t.cpp Tue Oct  9 10:06:34 2007
@@ -31,7 +31,6 @@
 
 #include <open/hythread_ext.h>
 #include <open/thread_helpers.h>
-#include "open/thread_externals.h"
 #include "open/jthread.h"
 
 #include <assert.h>

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ia32.cpp Tue Oct  9 10:06:34 2007
@@ -26,7 +26,6 @@
 
 #include <open/hythread_ext.h>
 #include <open/thread_helpers.h>
-#include "open/thread_externals.h"
 #include "open/jthread.h"
 
 #include <assert.h>

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ipf.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ipf.cpp?rev=583223&r1=583222&r2=583223&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ipf.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/thread/helpers/thread_helpers_ipf.cpp Tue Oct  9 10:06:34 2007
@@ -22,7 +22,6 @@
 
 #include <open/hythread_ext.h>
 #include <open/thread_helpers.h>
-#include "open/thread_externals.h"
 #include "open/jthread.h"
 
 #include <assert.h>