harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wjwashb...@apache.org
Subject svn commit: r520478 [1/2] - in /harmony/enhanced/drlvm/trunk: build/make/components/vm/ build/make/targets/ vm/em/src/ vm/include/open/ vm/tests/kernel/java/lang/ vm/tests/unit/thread/ vm/thread/src/ vm/thread/src/linux/ vm/thread/src/win/ vm/vmcore/in...
Date Tue, 20 Mar 2007 16:55:20 GMT
Author: wjwashburn
Date: Tue Mar 20 09:55:17 2007
New Revision: 520478

URL: http://svn.apache.org/viewvc?view=rev&rev=520478
Log:
Harmony-3288,  mods to make Thread Manager use real OS api instead of APR
build, build test passes on winxp32 and linux 32 rhel4, gcc 4.0.2


Added:
    harmony/enhanced/drlvm/trunk/vm/include/open/hycond_win.h
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_condvar.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_mutex.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_condvar.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_mutex.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/win/os_thread.c
Removed:
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_mutex.c
Modified:
    harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml
    harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml
    harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp
    harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h
    harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h
    harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ThreadTest.java
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c
    harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c
    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/thread_init.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_attrs.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.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/thread_ti_monitors.c
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_ti_timing.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_internal.h
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti.cpp
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_capability.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/thread/lock_manager.cpp

Modified: harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/components/vm/hythr.xml Tue Mar 20 09:55:17 2007
@@ -46,6 +46,12 @@
                 <include name="thread/src/*native*.c" />
                 <!-- include name="thread/src/*task*.c" / -->
                 <include name="thread/src/thread_init.c" />
+                <select os="win">
+                  <include name="thread/src/win/*.c" />
+                </select>
+                <select os="lnx">
+                  <include name="thread/src/linux/*.c" />
+                </select>
             </fileset>
 
             <select os="win" cfg="release" cxx="icl">

Modified: harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml (original)
+++ harmony/enhanced/drlvm/trunk/build/make/targets/cunit.test.xml Tue Mar 20 09:55:17 2007
@@ -131,7 +131,6 @@
 
                         <libset libs="hythr" dir="${build.semi.dir}/vm/hythr/_bin" />
                         <libset libs="encoder" dir="${build.semi.dir}/vm/encoder/_bin" />
-                        <libset libs="apr-1" dir="${build.semi.dir}/extra/apr/_bin" />
                         <libset libs="aprutil-1" dir="${build.semi.dir}/extra/aprutil/_bin" />
                         <libset libs="port" dir="${build.semi.dir}/vm/port/_bin" />
                         <libset libs="log4cxx" dir="${build.semi.dir}/extra/log4cxx/_bin" />

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/DrlEMImpl.cpp Tue Mar 20 09:55:17 2007
@@ -116,7 +116,7 @@
 
 DrlEMImpl::~DrlEMImpl() {
     deallocateResources();
-    hymutex_destroy(recompilationLock);
+    hymutex_destroy(&recompilationLock);
 }
 
 void DrlEMImpl::initProfileAccess() {
@@ -763,15 +763,15 @@
 
 void DrlEMImpl::methodProfileIsReady(MethodProfile* mp) {
     
-    hymutex_lock(recompilationLock);
+    hymutex_lock(&recompilationLock);
     if (methodsInRecompile.find((Method_Profile_Handle)mp)!=methodsInRecompile.end()) {
         //method is already recompiling by another thread or by this thread(recursion)
-        hymutex_unlock(recompilationLock);
+        hymutex_unlock(&recompilationLock);
         return;
     }
     methodsInRecompile.insert((Method_Profile_Handle)mp);
     nMethodsRecompiled++;
-    hymutex_unlock(recompilationLock);
+    hymutex_unlock(&recompilationLock);
 
     const char* methodName = NULL;
     const char* className = NULL;
@@ -812,9 +812,9 @@
             }
         }
     }
-    hymutex_lock(recompilationLock);
+    hymutex_lock(&recompilationLock);
     methodsInRecompile.erase((Method_Profile_Handle)mp);
-    hymutex_unlock(recompilationLock);
+    hymutex_unlock(&recompilationLock);
 }
 
 ProfileCollector* DrlEMImpl::getProfileCollector(EM_PCTYPE type, JIT_Handle jh, EM_JIT_PC_Role jitRole) const {

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EBProfileCollector.cpp Tue Mar 20 09:55:17 2007
@@ -112,7 +112,7 @@
         delete profile;
     }
 
-    hymutex_destroy(profilesLock);
+    hymutex_destroy(&profilesLock);
 }
 
 MethodProfile* EBProfileCollector::getMethodProfile(Method_Handle mh) const {
@@ -126,7 +126,7 @@
 EBMethodProfile* EBProfileCollector::createProfile(Method_Handle mh) {
     EBMethodProfile* profile = new EBMethodProfile(this, mh);
 
-    hymutex_lock(profilesLock);
+    hymutex_lock(&profilesLock);
 
     assert(profilesByMethod.find(mh) == profilesByMethod.end());
     profilesByMethod[mh] = profile;
@@ -134,7 +134,7 @@
     newProfiles.push_back(profile);
     }
 
-    hymutex_unlock(profilesLock);
+    hymutex_unlock(&profilesLock);
 
     return profile;
 }
@@ -155,10 +155,10 @@
 void EBProfileCollector::onTimeout() {
     assert(mode == EB_PCMODE_ASYNC);
     if(!newProfiles.empty()) {
-        hymutex_lock(profilesLock);
+        hymutex_lock(&profilesLock);
         greenProfiles.insert(greenProfiles.end(), newProfiles.begin(), newProfiles.end());
         newProfiles.clear();
-        hymutex_unlock(profilesLock);
+        hymutex_unlock(&profilesLock);
     }
 
     for (std::vector<EBMethodProfile*>::iterator it = greenProfiles.begin(), end = greenProfiles.end(); it!=end; ++it) {

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/EdgeProfileCollector.cpp Tue Mar 20 09:55:17 2007
@@ -113,7 +113,7 @@
         EdgeMethodProfile* profile = it->second;
         delete profile;
     }
-    hymutex_destroy(profilesLock);
+    hymutex_destroy(&profilesLock);
 }
 
 
@@ -176,7 +176,7 @@
                                                         uint32* counterKeys,
                                                         uint32 checkSum)
 {
-    hymutex_lock(profilesLock);
+    hymutex_lock(&profilesLock);
 
     EdgeMethodProfile* profile = new EdgeMethodProfile(this, mh);
 
@@ -192,7 +192,7 @@
     profilesByMethod[mh] = profile;
     newProfiles.push_back(profile);
 
-    hymutex_unlock(profilesLock);
+    hymutex_unlock(&profilesLock);
 
     return profile;
 }
@@ -234,10 +234,10 @@
 void EdgeProfileCollector::onTimeout()
 {
     if(!newProfiles.empty()) {
-        hymutex_lock(profilesLock);
+        hymutex_lock(&profilesLock);
         greenProfiles.insert(greenProfiles.end(), newProfiles.begin(), newProfiles.end());
         newProfiles.clear();
-        hymutex_unlock(profilesLock);
+        hymutex_unlock(&profilesLock);
     }
 
     std::vector<EdgeMethodProfile*>::iterator it = greenProfiles.begin();

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.cpp Tue Mar 20 09:55:17 2007
@@ -125,7 +125,7 @@
 
 ValueMethodProfile* ValueProfileCollector::createProfile(Method_Handle mh, uint32 numkeys, uint32 keys[])
 {
-    hymutex_lock(profilesLock);
+    hymutex_lock(&profilesLock);
     ValueMethodProfile* profile = new ValueMethodProfile(this, mh);
     VPInstructionProfileData* vpmap = new VPInstructionProfileData[numkeys];
     // Allocate space for value maps
@@ -147,7 +147,7 @@
     }
     assert(profilesByMethod.find(mh) == profilesByMethod.end());
     profilesByMethod[mh] = profile;
-    hymutex_unlock(profilesLock);
+    hymutex_unlock(&profilesLock);
     return profile;
 }
 
@@ -191,7 +191,7 @@
         ValueMethodProfile* profile = it->second;
         delete profile;
     }
-    hymutex_destroy(profilesLock);
+    hymutex_destroy(&profilesLock);
 }
 
 ValueMethodProfile::ValueMethodProfile(ValueProfileCollector* pc, Method_Handle mh)
@@ -202,7 +202,7 @@
 
 ValueMethodProfile::~ValueMethodProfile()
 {
-    hymutex_destroy(lock);
+    hymutex_destroy(&lock);
 }
 
 void ValueMethodProfile::addNewValue(uint32 instructionKey, POINTER_SIZE_INT valueToAdd)

Modified: harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/em/src/NValueProfileCollector.h Tue Mar 20 09:55:17 2007
@@ -91,8 +91,8 @@
 public:
     ValueMethodProfile(ValueProfileCollector* pc, Method_Handle mh);
     ~ValueMethodProfile();
-    void lockProfile() {hymutex_lock(lock);}
-    void unlockProfile() {hymutex_unlock(lock);}
+    void lockProfile() {hymutex_lock(&lock);}
+    void unlockProfile() {hymutex_unlock(&lock);}
     void dumpValues(std::ostream& os);
     void addNewValue(uint32 instructionKey, POINTER_SIZE_INT valueToAdd);
     POINTER_SIZE_INT getResult(uint32 instructionKey);

Added: harmony/enhanced/drlvm/trunk/vm/include/open/hycond_win.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/include/open/hycond_win.h?view=auto&rev=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hycond_win.h (added)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hycond_win.h Tue Mar 20 09:55:17 2007
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * Condition variable implementation for Windows, based on wait queues.
+ */
+#ifndef _HYCOND_WIN_H
+#define _HYCOND_WIN_H
+
+#ifndef _WIN32
+#error This code is only supposed to work on Windows
+#endif // _WIN32
+
+  #if _MSC_VER >= 1300 || __INTEL_COMPILER
+  // workaround for the
+  // http://www.microsoft.com/msdownload/platformsdk/sdkupdate/2600.2180.7/contents.htm
+  #include <winsock2.h>
+  #endif
+
+#include <windows.h>
+
+struct waiting_node {
+   // notification event
+   HANDLE event;
+   // doubly-linked queue
+   struct waiting_node *prev;
+   struct waiting_node *next;
+};
+
+// queue based condition implementation
+struct HyCond {
+    // Synchronization is necessary because signal() caller is not required
+    // to hold mutex associated with the condition variable.
+    hymutex_t queue_mutex;
+    // head-tail marker node
+    struct waiting_node dummy_node;
+};
+
+#endif // _HYCOND_WIN_H

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/include/open/hythread_ext.h Tue Mar 20 09:55:17 2007
@@ -116,6 +116,7 @@
 #if !defined(HYTHREAD_EXT_H)
 #define HYTHREAD_EXT_H
 
+#include "open/types.h"
 
 #if defined(__cplusplus)
 extern "C" {
@@ -129,8 +130,19 @@
  */
 //@{
 
-typedef struct HyMutex *hymutex_t;
-typedef struct HyCond  *hycond_t;
+#ifdef __linux__
+#include <pthread.h>
+#define hymutex_t pthread_mutex_t
+#define hycond_t pthread_cond_t
+#endif // __linux__
+
+#ifdef _WIN32
+#define hymutex_t CRITICAL_SECTION
+#define hycond_t struct HyCond
+#include "hycond_win.h"
+#endif // _WIN32
+
+
 typedef struct HyLatch *hylatch_t;
 typedef struct HyThreadGroup *hythread_group_t;
 typedef struct HyThread *hythread_iterator_t;
@@ -180,6 +192,7 @@
 
 UDATA VMCALL hythread_tls_get_offset(hythread_tls_key_t key);
 UDATA VMCALL hythread_tls_get_suspend_request_offset();
+UDATA VMCALL hythread_get_thread_times(hythread_t thread, int64* pkernel, int64* puser);
 
 
 //@}
@@ -188,12 +201,12 @@
 //@{
 
 IDATA VMCALL hycond_create (hycond_t *cond);
-IDATA VMCALL hycond_wait (hycond_t cond, hymutex_t mutex);
-IDATA VMCALL hycond_wait_timed (hycond_t cond, hymutex_t mutex, I_64 millis, IDATA nanos);
-IDATA VMCALL hycond_wait_interruptable (hycond_t cond, hymutex_t mutex, I_64 millis, IDATA nanos);
-IDATA VMCALL hycond_notify (hycond_t cond);
-IDATA VMCALL hycond_notify_all (hycond_t cond);
-IDATA VMCALL hycond_destroy (hycond_t cond);
+IDATA VMCALL hycond_wait (hycond_t *cond, hymutex_t *mutex);
+IDATA VMCALL hycond_wait_timed (hycond_t *cond, hymutex_t *mutex, I_64 millis, IDATA nanos);
+IDATA VMCALL hycond_wait_interruptable (hycond_t *cond, hymutex_t *mutex, I_64 millis, IDATA nanos);
+IDATA VMCALL hycond_notify (hycond_t *cond);
+IDATA VMCALL hycond_notify_all (hycond_t *cond);
+IDATA VMCALL hycond_destroy (hycond_t *cond);
 
 //@}
 /** @name Safe suspension support
@@ -254,10 +267,10 @@
 //@{
 
 IDATA hymutex_create (hymutex_t *mutex, UDATA flags);
-IDATA hymutex_lock(hymutex_t mutex);
-IDATA hymutex_trylock (hymutex_t mutex);
-IDATA hymutex_unlock (hymutex_t mutex);
-IDATA hymutex_destroy (hymutex_t mutex);
+IDATA hymutex_lock(hymutex_t *mutex);
+IDATA hymutex_trylock (hymutex_t *mutex);
+IDATA hymutex_unlock (hymutex_t *mutex);
+IDATA hymutex_destroy (hymutex_t *mutex);
 
 //@}
 /** @name Thin monitors support

Modified: harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ThreadTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ThreadTest.java?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ThreadTest.java (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/ThreadTest.java Tue Mar 20 09:55:17 2007
@@ -527,7 +527,7 @@
         ThreadGroup tg = new ThreadGroup("newGroup");
         String name = "t1";
         Square s = new Square(25);
-        Thread t = new Thread(tg, s, name, 1);
+        Thread t = new Thread(tg, s, name, 0);
         t.start();
         waitTime = waitDuration;
         StackTraceElement ste[] = t.getStackTrace();
@@ -549,7 +549,14 @@
         Square s = new Square(25);
         StackTraceElement ste[] = null; 
         try {
-            Thread t = new Thread(tg, s, name, Long.MAX_VALUE);
+            Thread t;
+            try {
+                t = new Thread(tg, s, name, Long.MAX_VALUE);
+            } catch (OutOfMemoryError e) {
+                // fall back to default stack size if can't allocate
+                // Long.MAX_VALUE bytes for stack
+                t = new Thread(tg, s, name, 0);
+            }
             t.start();
             waitTime = waitDuration;
             ste = t.getStackTrace();
@@ -1964,4 +1971,4 @@
             return;
         }
     }
-}
\ No newline at end of file
+}

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- 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 Mar 20 09:55:17 2007
@@ -41,6 +41,7 @@
     apr_pool_t *pool;
     void **args; 
     hythread_t thread = NULL;
+    int r;
     
     apr_pool_create(&pool, NULL);
 
@@ -49,13 +50,14 @@
     hythread_group_create((hythread_group_t *)&args[0]); 
     
     args[1] = apr_palloc(pool, sizeof(jthread_threadattr_t));
-    ((jthread_threadattr_t *)args[1])->stacksize = 1024;
+    ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
     ((jthread_threadattr_t *)args[1])->priority  = 1;
     
-    hythread_create_with_group(&thread, args[0], 1024, 1, 0, start_proc, args);
+    r = hythread_create_with_group(&thread, args[0], 1024000, 1, 0, start_proc, args);
+    tf_assert(r == 0 && "thread creation failed");
 
-    hythread_join(thread);
-    // TODO: should check that created thread finished without errors.
+    r = hythread_join(thread);
+    tf_assert(r == 0 && "thread join failed");
     return TEST_PASSED;
 }
 
@@ -145,6 +147,7 @@
     void **args; 
     hythread_t thread = NULL;
     hythread_group_t group = NULL;
+    int r;
     
     char *buf;
     int i = 10;
@@ -158,19 +161,21 @@
         args[0] = group; 
         
         args[1] = apr_palloc(pool, sizeof(jthread_threadattr_t));
-        ((jthread_threadattr_t *)args[1])->stacksize = 1024;
+        ((jthread_threadattr_t *)args[1])->stacksize = 1024000;
         ((jthread_threadattr_t *)args[1])->priority  = 1;
         
         thread = NULL;
 
-        hythread_create_with_group(&thread, group, 1024, 1, 0, start_proc, args);
+        r = hythread_create_with_group(&thread, group, 1024000, 1, 0, start_proc, args);
+        tf_assert(r == 0 && "thread creation failed");
         buf = (char *)apr_pcalloc(pool, sizeof(char)*12);
 
         /*
           sprintf(buf, "Thread %d\0", i);
           hythread_set_name(thread, buf);
         */
-        hythread_join(thread);
+        r = hythread_join(thread);
+        tf_assert(r == 0 && "thread join failed");
     }
 
     //check thread structures:

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance.h Tue Mar 20 09:55:17 2007
@@ -47,7 +47,7 @@
 /*
  * Locks for waiting
  */
-hymutex_t tm_mutex_lock = NULL;
+hymutex_t tm_mutex_lock;
 hycond_t tm_condition_lock = NULL;
 apr_thread_mutex_t* apr_mutex_lock = NULL;
 apr_thread_cond_t* apr_condition_lock = NULL;
@@ -55,7 +55,7 @@
 /*
 * Locks for concurrent mutex tests
 */
-hymutex_t tm_concurrent_mutex_lock = NULL;
+hymutex_t tm_concurrent_mutex_lock;
 apr_thread_mutex_t* apr_concurrent_mutex_lock = NULL;
 
 /*

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_basic.c Tue Mar 20 09:55:17 2007
@@ -31,9 +31,9 @@
 }
 
 int proc_waiting(void *args) {
-    hymutex_lock(tm_mutex_lock);
-    hycond_wait(tm_condition_lock, tm_mutex_lock);
-    hymutex_unlock(tm_mutex_lock);
+    hymutex_lock(&tm_mutex_lock);
+    hycond_wait(&tm_condition_lock, &tm_mutex_lock);
+    hymutex_unlock(&tm_mutex_lock);
     return 0;
 }
 
@@ -133,13 +133,12 @@
         for (i = 0; i < ITERATIONS; i++) {
             stat = hymutex_create(&tm_mutex_lock, APR_THREAD_MUTEX_DEFAULT);
             assert(!stat);
-            stat = hymutex_destroy(tm_mutex_lock);
+            stat = hymutex_destroy(&tm_mutex_lock);
             assert(!stat);
         }
         end = apr_time_now();
         difference = difference + (end - start);
     }
-    tm_mutex_lock = NULL;
     difference = difference / PERF_FIDELITY;
     tested_threads_destroy();
 
@@ -192,15 +191,15 @@
     for (j = 0; j < PERF_FIDELITY; j++) {
         start = apr_time_now();
         for (i = 0; i < ITERATIONS; i++) {
-            stat = hymutex_lock(tm_mutex_lock);
+            stat = hymutex_lock(&tm_mutex_lock);
             assert(!stat);
-            stat = hymutex_unlock(tm_mutex_lock);
+            stat = hymutex_unlock(&tm_mutex_lock);
             assert(!stat);
         }
         end = apr_time_now();
         difference = difference + (end - start);
     }
-    stat = hymutex_destroy(tm_mutex_lock);
+    stat = hymutex_destroy(&tm_mutex_lock);
     assert(!stat);
     difference = difference / PERF_FIDELITY;
     tested_threads_destroy();
@@ -254,15 +253,15 @@
     for (j = 0; j < PERF_FIDELITY; j++) {
         start = apr_time_now();
         for (i = 0; i < ITERATIONS; i++) {
-            stat = hymutex_trylock(tm_mutex_lock);
+            stat = hymutex_trylock(&tm_mutex_lock);
             assert(!stat);
-            stat = hymutex_unlock(tm_mutex_lock);
+            stat = hymutex_unlock(&tm_mutex_lock);
             assert(!stat);
         }
         end = apr_time_now();
         difference = difference + (end - start);
     }
-    stat = hymutex_destroy(tm_mutex_lock);
+    stat = hymutex_destroy(&tm_mutex_lock);
     assert(!stat);
     difference = difference / PERF_FIDELITY;
     tested_threads_destroy();
@@ -466,7 +465,7 @@
     assert(!stat);
     stat = hythread_join(thread);
     assert(!stat);
-    stat = hymutex_destroy(tm_mutex_lock);
+    stat = hymutex_destroy(&tm_mutex_lock);
     assert(!stat);
     stat = hycond_destroy(tm_condition_lock);
     assert(!stat);
@@ -562,7 +561,7 @@
     assert(!stat);
     stat = hythread_join(thread);
     assert(!stat);
-    stat = hymutex_destroy(tm_mutex_lock);
+    stat = hymutex_destroy(&tm_mutex_lock);
     assert(!stat);
     stat = hycond_destroy(tm_condition_lock);
     assert(!stat);

Modified: harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/tests/unit/thread/test_performance_concurrent_mutex.c Tue Mar 20 09:55:17 2007
@@ -52,9 +52,9 @@
 
     int j = 0;
 
-    hymutex_lock(tm_mutex_lock);
-    hycond_wait(tm_condition_lock, tm_mutex_lock);
-    hymutex_unlock(tm_mutex_lock);
+    hymutex_lock(&tm_mutex_lock);
+    hycond_wait(&tm_condition_lock, &tm_mutex_lock);
+    hymutex_unlock(&tm_mutex_lock);
 
     for (j = 0; j < iterations; j++) {
         hymutex_lock(tm_concurrent_mutex_lock);
@@ -308,11 +308,11 @@
         hythread_join(threads_array[i]);
     }       
     end = apr_time_now();
-    stat = hymutex_destroy(tm_concurrent_mutex_lock);
+    stat = hymutex_destroy(&tm_concurrent_mutex_lock);
     assert(!stat);
-    stat = hymutex_destroy(tm_mutex_lock);
+    stat = hymutex_destroy(&tm_mutex_lock);
     assert(!stat);
-    stat = hycond_destroy(tm_condition_lock);
+    stat = hycond_destroy(&tm_condition_lock);
     assert(!stat);
     return (end - start);
 }

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.def Tue Mar 20 09:55:17 2007
@@ -49,6 +49,7 @@
 hythread_get_self_id
 hythread_get_id
 hythread_get_thread
+hythread_get_thread_times
 hythread_struct_init
 hythread_cancel_all
 hythread_group_create
@@ -146,7 +147,6 @@
 array_create
 array_delete
 array_get
-get_local_pool
 get_java_thread_group
 
 Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/hythr.exp Tue Mar 20 09:55:17 2007
@@ -48,6 +48,7 @@
 hythread_get_self_id;
 hythread_get_id;
 hythread_get_thread;
+hythread_get_thread_times;
 hythread_struct_init;
 hythread_cancel_all;
 hythread_group_create;
@@ -157,7 +158,6 @@
 array_create;
 array_delete;
 array_get;
-get_local_pool;
 get_java_thread_group;
 
 Java_org_apache_harmony_drlvm_thread_ThreadHelper_getThreadIdOffset;

Added: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_condvar.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_condvar.c?view=auto&rev=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_condvar.c (added)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_condvar.c Tue Mar 20 09:55:17 2007
@@ -0,0 +1,98 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @file os_condvar.c
+ * @brief Binding of hycond to condition variables provided by Pthreads
+ */
+
+#include "thread_private.h"
+#include <open/hythread_ext.h>
+
+
+/** @name Conditional variable
+ */
+//@{
+
+/**
+ * waits on a condition variable, directly using OS interfaces.
+ *
+ * This function does not implement interruptability and thread state
+ * functionality, thus the caller of this function have to handle it.
+ */
+int os_cond_timedwait(hycond_t *cond, hymutex_t *mutex, I_64 ms, IDATA nano)
+{
+    int r = 0;
+    if (!ms && !nano) {
+        r = pthread_cond_wait(cond, mutex);
+    } else {
+        struct timespec abstime;
+        apr_time_t then = apr_time_now() + ms*1000 + nano/1000;
+        abstime.tv_sec = apr_time_sec(then);
+        abstime.tv_nsec = apr_time_usec(then)*1000 + nano%1000;
+        r = pthread_cond_timedwait(cond, mutex, &abstime);
+    }
+    if (r == ETIMEDOUT)
+        r = TM_ERROR_TIMEOUT;
+    else if (r == EINTR)
+        r = TM_ERROR_INTERRUPT;
+    return r;
+}
+
+
+/**
+ * Creates and initializes condition variable.
+ *
+ * @param[in] cond the address of the condition variable.
+ * @return 0 on success, non-zero otherwise.
+ */
+IDATA VMCALL hycond_create (hycond_t *cond) {
+    return pthread_cond_init(cond, NULL);
+}
+
+/**
+ * Signals a single thread that is blocking on the given condition variable
+ * to wake up.
+ *
+ * @param[in] cond the condition variable on which to produce the signal.
+ * @sa apr_thread_cond_signal()
+ */
+IDATA VMCALL hycond_notify (hycond_t *cond) {
+    return pthread_cond_signal(cond);
+}
+
+/**
+ * Signals all threads blocking on the given condition variable.
+ *
+ * @param[in] cond the condition variable on which to produce the broadcast.
+ * @sa apr_thread_cond_broadcast()
+ */
+IDATA VMCALL hycond_notify_all (hycond_t *cond) {
+    return pthread_cond_broadcast(cond);
+}
+
+/**
+ * Destroys the condition variable and releases the associated memory.
+ *
+ * @param[in] cond the condition variable to destroy
+ * @sa apr_thread_cond_destroy()
+ */
+IDATA VMCALL hycond_destroy (hycond_t *cond) {
+    return pthread_cond_destroy(cond);
+}
+
+//@}

Added: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_mutex.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_mutex.c?view=auto&rev=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_mutex.c (added)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_mutex.c Tue Mar 20 09:55:17 2007
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @file os_mutex.c
+ * @brief hymutex binding to Pthreads mutexes
+ */
+
+#include "thread_private.h"
+#include <open/hythread_ext.h>
+
+
+/** @name Mutex
+ *
+ */
+//@{
+
+/**
+ * Initializes a mutex.
+ *
+ * A memory for mutex must be preallocated.
+ *
+ * @param[in] mutex the address of the mutex to be initialized
+ * @param[in] flags Or'ed value of:
+ * <PRE>
+ *           APR_THREAD_MUTEX_DEFAULT   platform-optimal lock behavior.
+ *           APR_THREAD_MUTEX_NESTED    enable nested (recursive) locks.
+ *           APR_THREAD_MUTEX_UNNESTED  disable nested locks (non-recursive).
+ * </PRE>
+ */
+IDATA VMCALL hymutex_create (hymutex_t *mutex, UDATA flags) {
+    int r = 0;
+    if (flags & APR_THREAD_MUTEX_NESTED) {
+        pthread_mutexattr_t attr;
+        pthread_mutexattr_init(&attr);
+        r = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+        if (r) return r;
+        r = pthread_mutex_init(mutex, &attr);
+        pthread_mutexattr_destroy(&attr);
+    } else {
+        r = pthread_mutex_init(mutex, NULL);
+    }
+    return r;
+}
+
+/**
+ * Acquires the lock for the given mutex. If the mutex is already locked,
+ * the current thread will be put to sleep until the lock becomes available.
+ *
+ * @param[in] mutex the mutex on which to acquire the lock.
+ * @sa apr_thread_mutex_lock()
+ */
+IDATA VMCALL hymutex_lock(hymutex_t *mutex) {
+    return pthread_mutex_lock(mutex);
+}
+
+/**
+ * Attempts to acquire the lock for the given mutex.
+ *
+ * @param[in] mutex the mutex on which to attempt the lock acquiring.
+ * @sa apr_thread_mutex_trylock()
+ */
+IDATA VMCALL hymutex_trylock (hymutex_t *mutex) {
+    int r;
+    r = pthread_mutex_trylock(mutex);
+    if (r == EBUSY) return TM_ERROR_EBUSY;
+    return r;
+}
+
+/**
+ * Releases the lock for the given mutex.
+ *
+ * @param[in] mutex the mutex from which to release the lock.
+ * @sa apr_thread_mutex_unlock()
+ */
+IDATA VMCALL hymutex_unlock (hymutex_t *mutex) {
+    return pthread_mutex_unlock(mutex);
+}
+
+/**
+ * Destroys the mutex.
+ *
+ * @param[in] mutex the mutex to destroy.
+ * @sa apr_thread_mutex_destroy()
+ */
+IDATA VMCALL hymutex_destroy (hymutex_t *mutex) {
+    return pthread_mutex_destroy(mutex);
+}
+
+//@}

Added: 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?view=auto&rev=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (added)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Tue Mar 20 09:55:17 2007
@@ -0,0 +1,218 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include <assert.h>
+#include <apr_atomic.h>
+#include <linux/unistd.h>	// gettid()
+#include <sched.h>		// sched_param
+#include <semaphore.h>
+#include <unistd.h>
+
+#include "thread_private.h"
+
+_syscall0(pid_t,gettid)
+pid_t gettid(void);
+
+/**
+ * Creates new thread.
+ *
+ * @param[out] handle on success, thread handle is stored in memory pointed by handle
+ * @param stacksize size of stack to be allocated for a new thread
+ * @param priority priority of a new thread
+ * @param func function to be started on a new thread
+ * @param data value to be passed to a function started on a new thread
+ *
+ * @return 0 on success, TM_ERROR_OUT_OF_MEMORY if system is thread cannot be created because
+ *         of insufficient memory, system error otherwise.
+ */
+int os_thread_create(/* out */osthread_t* phandle, UDATA stacksize, UDATA priority,
+        int (VMAPICALL *func)(void*), void *data)
+{
+    pthread_t thread;
+    pthread_attr_t attr, *pattr = NULL;
+    int r;
+
+    if (stacksize != 0) {
+	pattr = &attr;
+	pthread_attr_init(pattr);
+	r = pthread_attr_setstacksize(pattr, stacksize);
+	if (r) {
+	    pthread_attr_destroy(pattr);
+	    return r;
+	}
+    }
+
+    r = pthread_create(&thread, pattr, (void*(*)(void*))func, data);
+
+    if (pattr)
+	pthread_attr_destroy(pattr);
+
+    if (r == 0) {
+        *phandle = thread;
+	// priority is set from within the thread context
+        return 0;
+    } else {
+        if (r == EAGAIN || r == ENOMEM) {
+	    // EAGAIN may be returned if PTHREAD_THREADS_MAX limit is exceeded
+            return TM_ERROR_OUT_OF_MEMORY;
+	}
+        return r;
+    }
+}
+
+/**
+ * Adjusts priority of the running thread.
+ *
+ * @param thread        handle of thread
+ * @param priority      new priority value
+ *
+ * @return              0 on success, system error otherwise
+ */
+int os_thread_set_priority(osthread_t os_thread, int priority)
+{
+    // setting thread priority on linux is only supported for current thread
+    if (os_thread == pthread_self()) {
+	int r;
+	struct sched_param param;
+	pid_t self = gettid();
+	param.sched_priority = priority;
+	r = sched_setparam(self, &param);
+	return r ? errno : 0;
+    } else {
+        // setting other thread priority not supported on linux
+        return 0;
+    }
+}
+
+/**
+ * Returns os handle of the current thread.
+ *
+ * @return current thread handle on success, NULL on error
+ */
+osthread_t os_thread_current()
+{
+    return pthread_self();
+}
+
+/**
+ * Terminates the os thread.
+ */
+int os_thread_cancel(osthread_t os_thread)
+{
+    return pthread_cancel(os_thread);
+}
+
+/**
+ * Joins the os thread.
+ *
+ * @param os_thread     thread handle
+ *
+ * @return              0 on success, systerm error otherwise
+ */
+int os_thread_join(osthread_t os_thread)
+{
+    void *status;
+    return pthread_join(os_thread, &status);
+}
+
+/**
+ * Causes the current thread to stop execution.
+ *
+ * @param status        returns status of a thread
+ */
+void os_thread_exit(int status)
+{
+    pthread_exit((void*)status);
+}
+
+static int yield_other_init_flag = 0;
+static sem_t yield_other_sem;
+
+static void yield_other_handler(int signum, siginfo_t* info, void* context) {
+    if (!yield_other_init_flag) return;
+    sem_post(&yield_other_sem);
+}
+
+static void init_thread_yield_other () {
+    struct sigaction sa;
+
+    // init notification semaphore
+    sem_init(&yield_other_sem, 0, 0);
+
+    // set signal handler
+    sigemptyset(&sa.sa_mask);
+    sa.sa_flags = SA_SIGINFO | SA_RESTART;
+    sa.sa_sigaction = yield_other_handler;
+    sigaction(SIGUSR2, &sa, NULL);
+}
+
+/**
+ * Sends a signal to a thread to make sure thread's write
+ * buffers are flushed.
+ */
+void os_thread_yield_other(osthread_t os_thread) {
+    static pthread_mutex_t yield_other_mutex = PTHREAD_MUTEX_INITIALIZER;
+    struct timespec timeout;
+    int r;
+
+    timeout.tv_sec = 0;
+    timeout.tv_nsec = 1000000;
+
+    pthread_mutex_lock(&yield_other_mutex);
+
+    if (!yield_other_init_flag) {
+        init_thread_yield_other();
+        yield_other_init_flag = 1;
+    }
+
+    assert(os_thread);
+    r = pthread_kill(os_thread, SIGUSR2);
+
+    if (r == 0) {
+	// signal sent, let's do timed wait to make sure the signal
+	// was actually delivered
+        sem_timedwait(&yield_other_sem, &timeout);
+    }
+
+    pthread_mutex_unlock(&yield_other_mutex);
+}
+
+/**
+ * Queries amount of user and kernel times consumed by the thread,
+ * in nanoseconds.
+ *
+ * @param os_thread     thread handle
+ * @param[out] pkernel  a pointer to a variable to store kernel time to
+ * @param[out] puser    a pointer to a variable to store user time to
+ *
+ * @return      0 on success, system error otherwise
+ */
+int os_get_thread_times(osthread_t os_thread, int64* pkernel, int64* puser)
+{
+    clockid_t clock_id;
+    struct timespec tp;
+    int r;
+
+    r = pthread_getcpuclockid(os_thread, &clock_id);
+    if (r) return r;
+
+    r = clock_gettime(clock_id, &tp);
+    if (r) return r;
+
+    *puser = tp.tv_sec * 1000000000ULL + tp.tv_nsec;
+    return 0;
+}

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_init.c Tue Mar 20 09:55:17 2007
@@ -39,8 +39,9 @@
 apr_threadkey_t *TM_THREAD_KEY;
 
 //Thread manager global lock
-hymutex_t TM_START_LOCK = NULL;
-hymutex_t FAT_MONITOR_TABLE_LOCK = NULL;
+hymutex_t TM_START_LOCK;
+static int TM_INITIALIZED = 0;
+hymutex_t FAT_MONITOR_TABLE_LOCK;
 #define GLOBAL_MONITOR_NAME "global_monitor"
 hythread_monitor_t p_global_monitor;
 
@@ -138,10 +139,8 @@
     }
     assert(TM_LIBRARY == lib);
 
-    // Check if someone already initialized the library.
-    if (TM_START_LOCK != NULL) {
-        return;
-    }
+    if (TM_INITIALIZED) return;
+    TM_INITIALIZED = 1;
      
     apr_status = apr_initialize();
     assert(apr_status == APR_SUCCESS);
@@ -206,7 +205,7 @@
     IDATA status;
     
     assert(self == hythread_self());
-    status = hymutex_lock(self->library->TM_LOCK);
+    status = hymutex_lock(&self->library->TM_LOCK);
     assert(status == TM_ERROR_NONE);
 }
 
@@ -219,7 +218,7 @@
     IDATA status;
 
     assert(self == hythread_self());
-    status = hymutex_unlock(self->library->TM_LOCK);
+    status = hymutex_unlock(&self->library->TM_LOCK);
     assert(status == TM_ERROR_NONE);
 }
 
@@ -236,13 +235,13 @@
     // we need not care about suspension if the thread
     // is not even tattached to hythread
     if (self == NULL)
-        return hymutex_lock(TM_LIBRARY->TM_LOCK);
+        return hymutex_lock(&TM_LIBRARY->TM_LOCK);
 
     // suspend_disable_count must be 0 on potentially
     // blocking operation to prevent suspension deadlocks,
     // meaning that the thread is safe for suspension
     saved_count = reset_suspend_disable();
-    r = hymutex_lock(TM_LIBRARY->TM_LOCK);
+    r = hymutex_lock(&TM_LIBRARY->TM_LOCK);
     if (r) return r;
 
     // make sure we do not get a global thread lock
@@ -250,10 +249,10 @@
     while (self->suspend_request) {
         // give up global thread lock before safepoint,
         // because this thread can be suspended at a safepoint
-        r = hymutex_unlock(TM_LIBRARY->TM_LOCK);
+        r = hymutex_unlock(&TM_LIBRARY->TM_LOCK);
         if (r) return r;
         hythread_safe_point();
-        r = hymutex_lock(TM_LIBRARY->TM_LOCK);
+        r = hymutex_lock(&TM_LIBRARY->TM_LOCK);
         if (r) return r;
     }
 
@@ -268,7 +267,7 @@
  * 
  */
 IDATA VMCALL hythread_global_unlock() {
-    return hymutex_unlock(TM_LIBRARY->TM_LOCK);;
+    return hymutex_unlock(&TM_LIBRARY->TM_LOCK);;
 }
 
 hythread_group_t  get_java_thread_group(void) {
@@ -319,11 +318,11 @@
 }
 
 IDATA acquire_start_lock() {
-    return hymutex_lock(TM_START_LOCK);
+    return hymutex_lock(&TM_START_LOCK);
 }
 
 IDATA release_start_lock() {
-    return hymutex_unlock(TM_START_LOCK);
+    return hymutex_unlock(&TM_START_LOCK);
 }
 
 /*

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_basic.c Tue Mar 20 09:55:17 2007
@@ -643,26 +643,26 @@
     jvmti_thread = hythread_get_private_data(native_thread);
     lib = native_thread->library;
 
-    status = hymutex_lock(lib->TM_LOCK);
+    status = hymutex_lock(&lib->TM_LOCK);
     if (status != TM_ERROR_NONE) return status;    
 
     if (lib->nondaemon_thread_count == 1 && !jvmti_thread->daemon) {
-        status = hymutex_unlock(lib->TM_LOCK);
+        status = hymutex_unlock(&lib->TM_LOCK);
         return status;
     }
 
     while ((!jvmti_thread->daemon && lib->nondaemon_thread_count > 1)
             || (jvmti_thread->daemon && lib->nondaemon_thread_count > 0)) {
-        status = hycond_wait(lib->nondaemon_thread_cond, lib->TM_LOCK);
+        status = hycond_wait(&lib->nondaemon_thread_cond, &lib->TM_LOCK);
         //check interruption and other problems
         TRACE(("TM wait for nondaemons notified, count: %d", lib->nondaemon_thread_count));
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(lib->TM_LOCK);
+            hymutex_unlock(&lib->TM_LOCK);
             return status;
         }
     }
     
-    status = hymutex_unlock(lib->TM_LOCK);
+    status = hymutex_unlock(&lib->TM_LOCK);
     return status;
 }
 
@@ -709,11 +709,11 @@
     
     lib = self->library;
 
-    status = hymutex_lock(lib->TM_LOCK);
+    status = hymutex_lock(&lib->TM_LOCK);
     if (status != TM_ERROR_NONE) return status;
     
     lib->nondaemon_thread_count++;
-    status = hymutex_unlock(lib->TM_LOCK);
+    status = hymutex_unlock(&lib->TM_LOCK);
     return status;
 }
 
@@ -723,11 +723,11 @@
 
     lib = self->library;
     
-    status = hymutex_lock(lib->TM_LOCK);
+    status = hymutex_lock(&lib->TM_LOCK);
     if (status != TM_ERROR_NONE) return status;
     
     if (lib->nondaemon_thread_count <= 0) {
-        status = hymutex_unlock(lib->TM_LOCK);
+        status = hymutex_unlock(&lib->TM_LOCK);
         if (status != TM_ERROR_NONE) return status;
         return TM_ERROR_ILLEGAL_STATE;
     }
@@ -735,14 +735,14 @@
     TRACE(("TM: nondaemons decreased, thread: %p count: %d\n", self, lib->nondaemon_thread_count));
     lib->nondaemon_thread_count--;
     if (lib->nondaemon_thread_count <= 1) {
-        status = hycond_notify_all(lib->nondaemon_thread_cond); 
+        status = hycond_notify_all(&lib->nondaemon_thread_cond); 
         TRACE(("TM: nondaemons all dead, thread: %p count: %d\n", self, lib->nondaemon_thread_count));
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(lib->TM_LOCK);
+            hymutex_unlock(&lib->TM_LOCK);
             return status;
         }
     }
     
-    status = hymutex_unlock(lib->TM_LOCK);
+    status = hymutex_unlock(&lib->TM_LOCK);
     return status;
 }

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_attrs.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_attrs.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_attrs.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_attrs.c Tue Mar 20 09:55:17 2007
@@ -36,14 +36,12 @@
  *                              HYTHREAD_PRIORITY_MIN<br>
  * 
  * @returns 0 on success or negative value on failure (priority wasn't changed)
- * 
- * 
  */
 IDATA VMCALL hythread_set_priority(hythread_t thread, UDATA priority) {
-    apr_status_t apr_status = apr_thread_set_priority(thread->os_handle, priority); 
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    int r = os_thread_set_priority(thread->os_handle, priority);
+    if (r) return r;
     thread->priority = priority;
-    return TM_ERROR_NONE;
+    return 0;
 }
 
 /**

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_basic.c Tue Mar 20 09:55:17 2007
@@ -40,7 +40,7 @@
 
 extern hythread_group_t TM_DEFAULT_GROUP;
 extern hythread_library_t TM_LIBRARY;
-static void* APR_THREAD_FUNC thread_start_proc(apr_thread_t* thd, void *p_args);
+static int VMAPICALL thread_start_proc(void *arg);
 static hythread_t allocate_thread();
 static void reset_thread(hythread_t thread);
 static IDATA register_to_group(hythread_t thread, hythread_group_t group);
@@ -91,13 +91,11 @@
  * @param[in] attr threadattr to use to determine how to create the thread, or NULL for default attributes
  * @param[in] func function to run in the new thread
  * @param[in] data argument to be passed to starting function
- * @sa apr_thread_create()
  */
 IDATA VMCALL hythread_create_with_group(hythread_t *ret_thread, hythread_group_t group, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) {
-    apr_threadattr_t *apr_attrs;
     hythread_t  new_thread;
     thread_start_proc_data * start_proc_data;
-    apr_status_t apr_status;
+    int r;
    
     if (ret_thread) {
         hythread_struct_init(ret_thread);
@@ -111,18 +109,12 @@
     }
 
     new_thread->library = hythread_self()->library;
-    if (stacksize) {
-        apr_threadattr_create(&apr_attrs, new_thread->pool);
-        apr_threadattr_stacksize_set(apr_attrs, stacksize);
-        new_thread->apr_attrs  = apr_attrs;
-    } else {
-        new_thread->apr_attrs = NULL;
-    }
-
     new_thread->priority = priority ? priority : HYTHREAD_PRIORITY_NORMAL;
     //new_thread->suspend_request = suspend ? 1 : 0;
     
-    start_proc_data = (thread_start_proc_data *) apr_palloc(new_thread->pool, sizeof(thread_start_proc_data));
+    start_proc_data =
+        (thread_start_proc_data *) malloc(sizeof(thread_start_proc_data));
+
     if (start_proc_data == NULL) {
         return TM_ERROR_OUT_OF_MEMORY;
     }
@@ -133,14 +125,15 @@
     start_proc_data->start_proc = func;
     start_proc_data->start_proc_args = data;
 
-    // Create APR thread using the given attributes;
-    apr_status = apr_thread_create(&(new_thread->os_handle), // new thread OS handle 
-            new_thread->apr_attrs,                           // thread attr created here
-            thread_start_proc,                               //
-            (void *)start_proc_data,                         //thread_proc attrs 
-            new_thread->pool); 
+    // we 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();
+    r = os_thread_create(&new_thread->os_handle, stacksize,
+            priority, thread_start_proc, (void *)start_proc_data);
+    assert(/* error */ r || new_thread->os_handle /* or thread created ok */);
+    hythread_global_unlock();
    
-    return CONVERT_ERROR(apr_status);
+    return r;
 }
 
 /**
@@ -177,9 +170,6 @@
  */
 IDATA hythread_attach_to_group(hythread_t * handle, hythread_library_t lib, hythread_group_t group) {
     hythread_t thread;
-    apr_thread_t *os_handle = NULL; 
-    apr_os_thread_t *os_thread;
-    apr_status_t apr_status;
 
     if (lib == NULL) {
         lib = TM_LIBRARY;
@@ -203,15 +193,8 @@
         return TM_ERROR_OUT_OF_MEMORY;
     }
     thread->library = lib;
-    os_thread = apr_palloc(thread->pool, sizeof(apr_os_thread_t));
-    if (os_thread == NULL) {
-        return TM_ERROR_OUT_OF_MEMORY;
-    } 
-    *os_thread = apr_os_thread_current();
-    apr_status = apr_os_thread_put(&os_handle, os_thread, thread->pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    
-    thread->os_handle = os_handle;
+    thread->os_handle = os_thread_current();
+    assert(thread->os_handle);
 
     TRACE(("TM: native attached: native: %p ",  tm_self_tls));
     
@@ -434,11 +417,11 @@
     // Report error in case current thread is not attached
     if (!thread) return TM_ERROR_UNATTACHED_THREAD;
     
-    hymutex_lock(thread->mutex);
+    hymutex_lock(&thread->mutex);
     thread->state |= TM_THREAD_STATE_SLEEPING;
-    status = condvar_wait_impl(thread->condition, thread->mutex, millis, nanos, interruptable);
+    status = condvar_wait_impl(&thread->condition, &thread->mutex, millis, nanos, interruptable);
     thread->state &= ~TM_THREAD_STATE_SLEEPING;
-    hymutex_unlock(thread->mutex);
+    hymutex_unlock(&thread->mutex);
 
     return (status == TM_ERROR_INTERRUPT && interruptable) ? TM_ERROR_INTERRUPT : TM_ERROR_NONE;
 }
@@ -541,7 +524,7 @@
  * @return none
  */
 void VMCALL hythread_cancel(hythread_t thread) {
-    apr_thread_cancel(thread->os_handle);
+    os_thread_cancel(thread->os_handle);
 }
 
 /** 
@@ -597,7 +580,9 @@
     
     // Acquire global TM lock to prevent concurrent access to thread list
     status = hythread_global_lock(NULL);
-    if (status != TM_ERROR_NONE) return status;
+    assert(status == 0);
+
+    assert(thread->os_handle);
 
     thread_set_self(thread);
     assert(thread == tm_self_tls);
@@ -631,22 +616,16 @@
  * @return created and initialized thread_t structure
  */
 static hythread_t allocate_thread() {
-    apr_pool_t *pool;
-    apr_status_t apr_status;
     hythread_t ptr;
     IDATA status;
 
-    apr_status = apr_pool_create(&pool, TM_POOL);
-    if ((apr_status != APR_SUCCESS) || (pool == NULL)) return NULL;
-
-    ptr = (hythread_t )apr_pcalloc(pool, sizeof(HyThread));
+    ptr = (hythread_t )calloc(1, sizeof(HyThread));
     if (ptr == NULL) return NULL;
 
-    ptr->pool       = pool;
-    ptr->os_handle  = NULL;
+    ptr->os_handle  = (osthread_t)NULL;
     ptr->priority   = HYTHREAD_PRIORITY_NORMAL;
     // not implemented
-    //ptr->big_thread_local_storage = (void **)apr_pcalloc(pool, sizeof(void*)*tm_tls_capacity);
+    //ptr->big_thread_local_storage = (void **)calloc(1, sizeof(void*)*tm_tls_capacity);
     
     // Suspension
     ptr->suspend_request = 0;
@@ -667,17 +646,17 @@
 }
 
 static void reset_thread(hythread_t thread) {
-    apr_status_t apr_status;
+    int r;
     IDATA status;
     if (thread->os_handle) {
-        apr_thread_join(&apr_status, thread->os_handle);
-        assert(!apr_status);
+        r = os_thread_join(thread->os_handle);
+        assert(!r);
     }
 
-    thread->os_handle  = NULL;
+    thread->os_handle  = (osthread_t)NULL;
     thread->priority   = HYTHREAD_PRIORITY_NORMAL;
     // not implemented
-    //ptr->big_thread_local_storage = (void **)apr_pcalloc(pool, sizeof(void*)*tm_tls_capacity);
+    //ptr->big_thread_local_storage = (void **)calloc(1, sizeof(void*)*tm_tls_capacity);
 
     // Suspension
     thread->suspend_request = 0;
@@ -696,30 +675,36 @@
 // Wrapper around user thread start proc. Used to perform some duty jobs 
 // right after thread is started.
 //////
-static void* APR_THREAD_FUNC thread_start_proc(apr_thread_t* thd, void *p_args) {
+static int VMAPICALL thread_start_proc(void *arg) {
     IDATA status;
     hythread_t thread;
     thread_start_proc_data * start_proc_data;
+    hythread_entrypoint_t start_proc;
+    hythread_group_t group;
+    void *data;
     
-    start_proc_data = (thread_start_proc_data *) p_args;
+    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);
 
     TRACE(("TM: native thread started: native: %p tm: %p", apr_os_thread_current(), thread));
 
-    status = register_to_group(thread, start_proc_data->group);
+    status = register_to_group(thread, group);
     if (status != TM_ERROR_NONE) {
         thread->exit_value = status;
-        return &thread->exit_value;
+        return thread->exit_value;
     }
 
     // Also, should it be executed under TM global lock?
-    thread->os_handle = thd; // DELETE?
     status = hythread_set_priority(thread, thread->priority);
     //assert(status == TM_ERROR_NONE);//now we down - fixme
     thread->state |= TM_THREAD_STATE_RUNNABLE;
 
     // Do actual call of the thread body supplied by the user.
-    start_proc_data->start_proc(start_proc_data->start_proc_args);
+    start_proc(data);
 
     // Shutdown sequence.
     status = hythread_global_lock(NULL);
@@ -735,9 +720,7 @@
     status = hythread_global_unlock(NULL);
     assert(status == TM_ERROR_NONE);    
     
-    // TODO: It seems it is there is no need to call apr_thread_exit.
-    // Current thread should automatically exit upon returning from this function.
-    return (void *)(IDATA)apr_thread_exit(thd, APR_SUCCESS);
+    return 0;
 }
 
 extern HY_CFUNC void VMCALL 
@@ -747,20 +730,20 @@
         monitor->recursion_count = 0;
         hythread_monitor_exit(monitor);
     }
-    apr_thread_exit(hythread_self()->os_handle, APR_SUCCESS);     
+    os_thread_exit(0);
     // unreachable statement
     abort();
 }
 
-apr_pool_t* get_local_pool() {
-    hythread_t self = tm_self_tls;
-    return self == NULL ? TM_POOL : self->pool;
-}
- 
 /**
-  * TODO: implement this function to reduce memory leaks.
-  */
-IDATA local_pool_cleanup_register(void* func, void* data) {
-   return TM_ERROR_NONE;
+ * Queries user and kernel time of the thread, in nanoseconds.
+ *
+ * @param thread        thread block pointer
+ * @param[out] pkernel  pointer to a variable to store kernel time into
+ * @param[out] puser    pointer to a variable to store user time into
+ *
+ * @returns     0 on success, system error code otherwise
+ */
+UDATA hythread_get_thread_times(hythread_t thread, int64* pkernel, int64* puser) {
+    return os_get_thread_times(thread->os_handle, pkernel, puser);
 }
-

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c Tue Mar 20 09:55:17 2007
@@ -29,54 +29,44 @@
 //@{
 
 /**
- * Creates and initializes condition variable.
- *
- * @param[out] cond the memory address where the newly created condition variable
- * will be stored.
- * @sa apr_thread_cond_create()
+ * Waits on a conditional, handling interruptions and thread state.
  */
-IDATA VMCALL hycond_create (hycond_t *cond) {
-    apr_pool_t *pool = get_local_pool(); 
-    apr_status_t apr_status = apr_thread_cond_create((apr_thread_cond_t**)cond, pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    return TM_ERROR_NONE;
-}
-
-IDATA condvar_wait_impl(hycond_t cond, hymutex_t mutex, I_64 ms, IDATA nano, IDATA interruptable) {
-    apr_status_t apr_status;
+IDATA condvar_wait_impl(hycond_t *cond, hymutex_t *mutex, I_64 ms, IDATA nano, IDATA interruptable) {
+    int r;
     int disable_count;
-    hythread_t this_thread;
+    hythread_t self;
     
-    this_thread = tm_self_tls;    
+    self = tm_self_tls;
     
     // Store provided cond into current thread cond
-    this_thread->current_condition = interruptable ? cond : NULL;
+    self->current_condition = interruptable ? cond : NULL;
 
     // check interrupted flag
-    if (interruptable && (this_thread->state & TM_THREAD_STATE_INTERRUPTED)) {
+    if (interruptable && (self->state & TM_THREAD_STATE_INTERRUPTED)) {
         // clean interrupted flag
-        this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED);
-                return TM_ERROR_INTERRUPT;
+        hymutex_lock(&self->mutex);
+        self->state &= ~TM_THREAD_STATE_INTERRUPTED;
+        hymutex_unlock(&self->mutex);
+        return TM_ERROR_INTERRUPT;
     }
 
     disable_count = reset_suspend_disable(); 
-    // Delegate to OS wait
-    apr_status = (!ms && !nano)?
-        apr_thread_cond_wait((apr_thread_cond_t*)cond, (apr_thread_mutex_t*)mutex):
-	apr_thread_cond_timedwait ((apr_thread_cond_t*)cond, (apr_thread_mutex_t*)mutex, ms*1000 + ((nano < 1000) ? 1 : (nano / 1000)));
-        
-    set_suspend_disable(disable_count);
 
-    this_thread->current_condition = NULL;
+    r = os_cond_timedwait(cond, mutex, ms, nano);
+
+    set_suspend_disable(disable_count);
+    self->current_condition = NULL;
    
     // check interrupted flag
-    if (interruptable &&  (this_thread->state & TM_THREAD_STATE_INTERRUPTED)) {
+    if (interruptable &&  (self->state & TM_THREAD_STATE_INTERRUPTED)) {
         // clean interrupted flag
-        this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED);
+        hymutex_lock(&self->mutex);
+        self->state &= (~TM_THREAD_STATE_INTERRUPTED);
+        hymutex_unlock(&self->mutex);
         return TM_ERROR_INTERRUPT;
     }
 
-    return CONVERT_ERROR(apr_status);
+    return r;
 }
 
 /**
@@ -88,8 +78,8 @@
  * @return  
  *      TM_NO_ERROR on success 
  */
-IDATA VMCALL hycond_wait(hycond_t cond, hymutex_t mutex) {
-    return condvar_wait_impl(cond, mutex, 0, 0, 0);
+IDATA VMCALL hycond_wait(hycond_t *cond, hymutex_t *mutex) {
+    return condvar_wait_impl(cond, mutex, 0, 0, WAIT_NONINTERRUPTABLE);
 }
 
 /**
@@ -104,8 +94,8 @@
  * @return  
  *      TM_NO_ERROR on success 
  */
-IDATA VMCALL hycond_wait_timed(hycond_t cond, hymutex_t mutex, I_64 ms, IDATA nano) {
-    return condvar_wait_impl(cond, mutex, ms, nano, 0);
+IDATA VMCALL hycond_wait_timed(hycond_t *cond, hymutex_t *mutex, I_64 ms, IDATA nano) {
+    return condvar_wait_impl(cond, mutex, ms, nano, WAIT_NONINTERRUPTABLE);
 }
 
 /**
@@ -121,48 +111,8 @@
  *      TM_NO_ERROR on success 
  *      TM_THREAD_INTERRUPTED in case thread was interrupted during wait.
  */
-IDATA VMCALL hycond_wait_interruptable(hycond_t cond, hymutex_t mutex, I_64 ms, IDATA nano) {
+IDATA VMCALL hycond_wait_interruptable(hycond_t *cond, hymutex_t *mutex, I_64 ms, IDATA nano) {
     return condvar_wait_impl(cond, mutex, ms, nano, WAIT_INTERRUPTABLE);
-}
-
-/**
- * Signals a single thread that is blocking on the given condition variable to wake up. 
- *
- * @param[in] cond the condition variable on which to produce the signal.
- * @sa apr_thread_cond_signal()
- */
-IDATA VMCALL hycond_notify (hycond_t cond) {
-    apr_status_t apr_status = apr_thread_cond_signal((apr_thread_cond_t*)cond);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    return TM_ERROR_NONE;
-}
-
-/**
- * Signals all threads blocking on the given condition variable.
- * 
- * @param[in] cond the condition variable on which to produce the broadcast.
- * @sa apr_thread_cond_broadcast()
- */
-IDATA VMCALL hycond_notify_all (hycond_t cond) {
-    apr_status_t apr_status = apr_thread_cond_broadcast((apr_thread_cond_t*)cond);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    return TM_ERROR_NONE;   
-}
-
-/**
- * Destroys the condition variable and releases the associated memory.
- *
- * @param[in] cond the condition variable to destroy
- * @sa apr_thread_cond_destroy()
- */
-IDATA VMCALL hycond_destroy (hycond_t cond) {
-    apr_status_t apr_status;
-    apr_pool_t *pool = apr_thread_cond_pool_get ((apr_thread_cond_t*)cond);
-    if (pool != get_local_pool()) {
-          return local_pool_cleanup_register(hycond_destroy, cond);
-    }
-    apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)cond);
-    return CONVERT_ERROR(apr_status);
 }
 
 //@}

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c Tue Mar 20 09:55:17 2007
@@ -43,21 +43,18 @@
  *
  */
 IDATA VMCALL hythread_monitor_init_with_name(hythread_monitor_t *mon_ptr, UDATA flags, char *name) {
+    int r;
     hythread_monitor_t mon;
-    apr_pool_t *pool = get_local_pool();
-    apr_status_t apr_status;
 
-    mon = apr_pcalloc(pool, sizeof(HyThreadMonitor));
+    mon = calloc(1, sizeof(HyThreadMonitor));
     if (mon == NULL) {
         return TM_ERROR_OUT_OF_MEMORY;
     }
-    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(mon->mutex), TM_MUTEX_NESTED, pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    r = hymutex_create(&mon->mutex, TM_MUTEX_NESTED);
+    if (r) goto cleanup;
+    r = hycond_create(&mon->condition);
+    if (r) goto cleanup;
 
-    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(mon->condition), pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-
-    mon->pool  = pool;
     mon->flags = flags;
     mon->name  = name;
     mon->owner = 0;
@@ -65,6 +62,10 @@
 
     *mon_ptr = mon;
     return TM_ERROR_NONE;
+
+cleanup:
+    free(mon);
+    return r;
 }
 
 /**
@@ -84,7 +85,7 @@
     IDATA status;
     hythread_t  self = tm_self_tls;
     if (mon_ptr->owner != self) {
-        status = hymutex_lock(mon_ptr->mutex);
+        status = hymutex_lock(&mon_ptr->mutex);
         mon_ptr->owner = self;
         assert(status == TM_ERROR_NONE);
     } else {
@@ -112,7 +113,7 @@
     IDATA status;
     hythread_t self = tm_self_tls;
     if (mon_ptr->owner != self) {
-        status = hymutex_trylock(mon_ptr->mutex);
+        status = hymutex_trylock(&mon_ptr->mutex);
         if (status == TM_ERROR_NONE) {
             mon_ptr->owner = tm_self_tls;
         }
@@ -146,7 +147,7 @@
     }
     if (mon_ptr->recursion_count == 0) {
         mon_ptr->owner = NULL;
-        status = hymutex_unlock(mon_ptr->mutex);
+        status = hymutex_unlock(&mon_ptr->mutex);
     } else {
         mon_ptr->recursion_count--;
     }
@@ -175,17 +176,17 @@
     mon_ptr->owner = NULL;
     mon_ptr->recursion_count =0;
     mon_ptr->wait_count++;
-    hymutex_lock(self->mutex);
-    self->current_condition = mon_ptr->condition;
+    hymutex_lock(&self->mutex);
+    self->current_condition = &mon_ptr->condition;
     self->state |= TM_THREAD_STATE_IN_MONITOR_WAIT;
     self->waited_monitor = mon_ptr;
-    hymutex_unlock(self->mutex);
+    hymutex_unlock(&self->mutex);
 
     do {
         apr_time_t start;
         assert(0 <= mon_ptr->notify_flag && mon_ptr->notify_flag < mon_ptr->wait_count);
         start = apr_time_now();
-        status = condvar_wait_impl(mon_ptr->condition, mon_ptr->mutex, ms, nano, interruptable);
+        status = condvar_wait_impl(&mon_ptr->condition, &mon_ptr->mutex, ms, nano, interruptable);
         if (status != TM_ERROR_NONE
                 || mon_ptr->notify_flag || hythread_interrupted(self))
             break;
@@ -210,19 +211,19 @@
     } while (1);
     if (mon_ptr->notify_flag)
         mon_ptr->notify_flag -= 1;
-    hymutex_lock(self->mutex);
+    hymutex_lock(&self->mutex);
     self->state &= ~TM_THREAD_STATE_IN_MONITOR_WAIT;
     self->current_condition = NULL;
     self->waited_monitor = NULL;
-    hymutex_unlock(self->mutex);
+    hymutex_unlock(&self->mutex);
     mon_ptr->wait_count--;
 
     if (self->suspend_request) {
         int save_count;
-        hymutex_unlock(mon_ptr->mutex);
+        hymutex_unlock(&mon_ptr->mutex);
         hythread_safe_point();
         save_count = reset_suspend_disable();
-        hymutex_lock(mon_ptr->mutex);
+        hymutex_lock(&mon_ptr->mutex);
         set_suspend_disable(save_count);
     }
 
@@ -325,7 +326,7 @@
         return TM_ERROR_ILLEGAL_STATE;
     }
     mon_ptr->notify_flag = mon_ptr->wait_count;
-    return hycond_notify_all(mon_ptr->condition);
+    return hycond_notify_all(&mon_ptr->condition);
 }
 
 
@@ -348,7 +349,7 @@
     }
     if (mon_ptr->notify_flag < mon_ptr->wait_count)
         mon_ptr->notify_flag += 1;
-    return hycond_notify(mon_ptr->condition);
+    return hycond_notify(&mon_ptr->condition);
 }
 
 
@@ -367,20 +368,13 @@
  * @see hythread_monitor_init_with_name
  */
 IDATA VMCALL hythread_monitor_destroy(hythread_monitor_t monitor) {
-    apr_status_t apr_status;
-    apr_pool_t *pool = monitor->pool;
     if (monitor->owner != NULL || monitor->wait_count > 0) {
         return TM_ERROR_ILLEGAL_STATE;
     }
 
-    if (pool != get_local_pool()) {
-        return local_pool_cleanup_register(hythread_monitor_destroy, monitor);
-    }
-    apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)monitor->mutex);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)monitor->condition);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    // apr_pool_free(pool, monitor);
+    hymutex_destroy(&monitor->mutex);
+    hycond_destroy(&monitor->condition);
+    free(monitor);
     return TM_ERROR_NONE;
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_interrupt.c Tue Mar 20 09:55:17 2007
@@ -38,11 +38,11 @@
 void VMCALL hythread_interrupt(hythread_t thread) {
     IDATA status;
     hythread_t thr = NULL;
-    hymutex_lock(thread->mutex);
+    hymutex_lock(&thread->mutex);
     thread->state |= TM_THREAD_STATE_INTERRUPTED;
     
     if (thread == tm_self_tls) {
-        hymutex_unlock(thread->mutex);
+        hymutex_unlock(&thread->mutex);
         return;
     }
 
@@ -62,29 +62,29 @@
 	}
     }
 
-    hymutex_unlock(thread->mutex);
+    hymutex_unlock(&thread->mutex);
 }
+
 static int interrupter_thread_function(void *args) {
     hythread_t thread = (hythread_t)args; 
     hythread_monitor_t monitor = NULL;
-    hymutex_lock(thread->mutex);
+    hymutex_lock(&thread->mutex);
 
     if (thread->waited_monitor) {
         monitor = thread->waited_monitor;
     } else {
-        hymutex_unlock(thread->mutex);
+        hymutex_unlock(&thread->mutex);
         hythread_exit(NULL);
         return 0; 
     } 
 
-    hymutex_unlock(thread->mutex);
-
+    hymutex_unlock(&thread->mutex);
 
-   hythread_monitor_enter(monitor);
-   hythread_monitor_notify_all(monitor);
+    hythread_monitor_enter(monitor);
+    hythread_monitor_notify_all(monitor);
 
-   hythread_exit(monitor);
-   return 0;
+    hythread_exit(monitor);
+    return 0;
 }
 
 /** 
@@ -95,10 +95,10 @@
  */
 UDATA VMCALL hythread_clear_interrupted_other(hythread_t thread) {
     int interrupted;
-    hymutex_lock(thread->mutex);
+    hymutex_lock(&thread->mutex);
     interrupted = thread->state & TM_THREAD_STATE_INTERRUPTED;
     thread->state &= ~TM_THREAD_STATE_INTERRUPTED;
-    hymutex_unlock(thread->mutex);
+    hymutex_unlock(&thread->mutex);
     return interrupted ? TM_ERROR_INTERRUPT : TM_ERROR_NONE;
 }
 

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_latch.c Tue Mar 20 09:55:17 2007
@@ -41,25 +41,25 @@
  * @sa java.util.concurrent.CountDownLatch 
  */
 IDATA VMCALL hylatch_create(hylatch_t *latch, IDATA count) {
+    int r;
     hylatch_t l;
-    apr_pool_t *pool = get_local_pool(); 
-    apr_status_t apr_status;
     
-    l = apr_palloc(pool, sizeof(HyLatch));
+    l = malloc(sizeof(HyLatch));
     if (l == NULL) {
-            return TM_ERROR_OUT_OF_MEMORY;
+        return TM_ERROR_OUT_OF_MEMORY;
     }
-    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    r = hymutex_create(&l->mutex, TM_MUTEX_DEFAULT);
+    if (r) goto cleanup;
+    r = hycond_create(&l->condition);
+    if (r) goto cleanup;
         
-    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool);
-
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-
     l->count = count;
-    l->pool = pool;
     *latch = l;
     return TM_ERROR_NONE;
+
+cleanup:
+    free(l);
+    return r;
 }
 
 //wait method implementation
@@ -67,19 +67,19 @@
 static IDATA latch_wait_impl(hylatch_t latch, I_64 ms, IDATA nano, IDATA interruptable) {
     IDATA status;
         
-    status = hymutex_lock(latch->mutex);
+    status = hymutex_lock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
     while (latch->count) {
-        status = condvar_wait_impl(latch->condition, latch->mutex, ms, nano, interruptable);
+        status = condvar_wait_impl(&latch->condition, &latch->mutex, ms, nano, interruptable);
         //check interruption and other problems
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(latch->mutex);
+            hymutex_unlock(&latch->mutex);
             return status;
         }
 
         if (ms || nano) break;
     }
-    status = hymutex_unlock(latch->mutex);
+    status = hymutex_unlock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;
@@ -136,10 +136,10 @@
 IDATA VMCALL hylatch_set(hylatch_t latch, IDATA count) {
     IDATA status;
     
-    status = hymutex_lock(latch->mutex);
+    status = hymutex_lock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
     latch->count = count;
-    status = hymutex_unlock(latch->mutex);
+    status = hymutex_unlock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;       
@@ -155,23 +155,23 @@
 IDATA VMCALL hylatch_count_down(hylatch_t latch) {
     IDATA status;
     
-    status = hymutex_lock(latch->mutex);
+    status = hymutex_lock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
     if (latch->count <= 0) {
-        status = hymutex_unlock(latch->mutex);
+        status = hymutex_unlock(&latch->mutex);
         if (status != TM_ERROR_NONE) return status;
         return TM_ERROR_ILLEGAL_STATE;
     }
     latch->count--;
     if (latch->count == 0) {
-        status = hycond_notify_all(latch->condition); 
+        status = hycond_notify_all(&latch->condition); 
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(latch->mutex);
+            hymutex_unlock(&latch->mutex);
             return status;
         }
     }
             
-    status = hymutex_unlock(latch->mutex);
+    status = hymutex_unlock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
         
     return TM_ERROR_NONE;       
@@ -188,10 +188,10 @@
 IDATA VMCALL hylatch_get_count(IDATA *count, hylatch_t latch) {
     IDATA status;
     
-    status = hymutex_lock(latch->mutex);
+    status = hymutex_lock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
     *count = latch->count;
-    status = hymutex_unlock(latch->mutex);
+    status = hymutex_unlock(&latch->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;       
@@ -202,14 +202,10 @@
  * @param[in] latch the latch 
  */
 IDATA VMCALL hylatch_destroy(hylatch_t latch) {
-    apr_pool_t *pool = latch->pool;
-    if (pool != get_local_pool()) {
-        return local_pool_cleanup_register(hylatch_destroy, latch);
-    }
-    apr_thread_mutex_destroy((apr_thread_mutex_t*)latch->mutex);
-    apr_thread_cond_destroy((apr_thread_cond_t*)latch->condition);
-    // apr_pool_free(pool, latch);
+    hymutex_destroy(&latch->mutex);
+    hycond_destroy(&latch->condition);
 
+    free(latch);
     return TM_ERROR_NONE;       
 }
 

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_park.c Tue Mar 20 09:55:17 2007
@@ -46,16 +46,16 @@
      hythread_t t = tm_self_tls;     
      assert(t);
 
-     hymutex_lock(t->mutex);
+     hymutex_lock(&t->mutex);
 
      if (t->state & TM_THREAD_STATE_UNPARKED) {
         t->state &= ~TM_THREAD_STATE_UNPARKED;
-        hymutex_unlock(t->mutex);
+        hymutex_unlock(&t->mutex);
         return (t->state & TM_THREAD_STATE_INTERRUPTED) ? TM_ERROR_INTERRUPT : TM_ERROR_NONE;
      }
 
      t->state |= TM_THREAD_STATE_PARKED;
-     status = hycond_wait_interruptable(t->condition, t->mutex, millis, nanos);
+     status = hycond_wait_interruptable(&t->condition, &t->mutex, millis, nanos);
      t->state &= ~TM_THREAD_STATE_PARKED;
 
      //the status should be restored for j.u.c.LockSupport
@@ -63,7 +63,7 @@
          t->state |= TM_THREAD_STATE_INTERRUPTED;
      }
 
-     hymutex_unlock(t->mutex);
+     hymutex_unlock(&t->mutex);
      return status;
 }
 
@@ -83,14 +83,14 @@
         return;
     }
     
-    hymutex_lock(thread->mutex);
+    hymutex_lock(&thread->mutex);
 
     if (thread->state & TM_THREAD_STATE_PARKED) {
         thread->state &= ~TM_THREAD_STATE_PARKED;
-        hycond_notify_all(thread->condition);
+        hycond_notify_all(&thread->condition);
     } else {
         thread->state |= TM_THREAD_STATE_UNPARKED;
     }
 
-    hymutex_unlock(thread->mutex);
+    hymutex_unlock(&thread->mutex);
 }

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_semaphore.c Tue Mar 20 09:55:17 2007
@@ -36,40 +36,41 @@
  * @param[in] max_count  maximum semaphore count
  */
 IDATA VMCALL hysem_create(hysem_t *sem, UDATA initial_count, UDATA max_count) {
+    int r;
     hysem_t l;
-    apr_pool_t *pool = get_local_pool(); 
-    apr_status_t apr_status;
     
-    l = apr_palloc(pool, sizeof(HySemaphore));
+    l = malloc(sizeof(HySemaphore));
     if (l == NULL) {
-            return TM_ERROR_OUT_OF_MEMORY;
+        return TM_ERROR_OUT_OF_MEMORY;
     }
-    apr_status = apr_thread_mutex_create((apr_thread_mutex_t**)&(l->mutex), TM_MUTEX_DEFAULT, pool);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
+    r = hymutex_create(&l->mutex, TM_MUTEX_DEFAULT);
+    if (r) goto cleanup;
+    r = hycond_create(&l->condition);
+    if (r) goto cleanup;
         
-    apr_status = apr_thread_cond_create((apr_thread_cond_t**)&(l->condition), pool);
-
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
     l->count = initial_count;
     l->max_count = max_count;
-    l->pool = pool;
     *sem = l;
     return TM_ERROR_NONE;
+
+cleanup:
+    free(l);
+    return r;
 }
 
 
 IDATA sem_wait_impl(hysem_t sem, I_64 ms, IDATA nano, IDATA interruptable) {
     IDATA status;
         
-    status = hymutex_lock(sem->mutex);
+    status = hymutex_lock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
     //printf("wait %x %d\n", sem, sem->count);
     //fflush(NULL);
     while (sem->count <= 0) {
-        status = condvar_wait_impl(sem->condition, sem->mutex, ms, nano, interruptable);
+        status = condvar_wait_impl(&sem->condition, &sem->mutex, ms, nano, interruptable);
         //check interruption and timeout
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(sem->mutex);
+            hymutex_unlock(&sem->mutex);
             return status;
         }
 
@@ -78,14 +79,14 @@
     //should we check here if timeout is not supposed to happen
     if (sem->count == 0 /*&& (ms || nano)*/) {
         if (ms || nano) {
-            hymutex_unlock(sem->mutex);
+            hymutex_unlock(&sem->mutex);
             return TM_ERROR_TIMEOUT;
         } else {
             assert(0);
         }
     }
     sem->count--;
-    status = hymutex_unlock(sem->mutex);
+    status = hymutex_unlock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;
@@ -149,20 +150,20 @@
     IDATA status;
     //printf("post %x %d\n", sem, sem->count);
     //fflush(NULL);
-    status = hymutex_lock(sem->mutex);
+    status = hymutex_lock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
     if (sem->count >= sem->max_count) {
-        hymutex_unlock(sem->mutex);
+        hymutex_unlock(&sem->mutex);
         //printf("illegal state %d : %d \n", sem->count, sem->max_count);
         //fflush(NULL);
         return TM_ERROR_ILLEGAL_STATE;
     }
     sem->count++;
     if (sem->count > 0) {
-        hycond_notify(sem->condition);
+        hycond_notify(&sem->condition);
     }
             
-    status = hymutex_unlock(sem->mutex);
+    status = hymutex_unlock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
     return TM_ERROR_NONE;
 }
@@ -176,22 +177,22 @@
 IDATA VMCALL hysem_set(hysem_t sem, IDATA count) {
     IDATA status;
     
-    status = hymutex_lock(sem->mutex);
+    status = hymutex_lock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
     if (count > sem->max_count) {
-        hymutex_unlock(sem->mutex);
+        hymutex_unlock(&sem->mutex);
         if (status != TM_ERROR_NONE) return status;
         return TM_ERROR_ILLEGAL_STATE;
     }
     sem->count = count;
     if (count > 0) {
-        status = hycond_notify_all(sem->condition); 
+        status = hycond_notify_all(&sem->condition); 
         if (status != TM_ERROR_NONE) {
-            hymutex_unlock(sem->mutex);
+            hymutex_unlock(&sem->mutex);
             return status;
         }
     }
-    status = hymutex_unlock(sem->mutex);
+    status = hymutex_unlock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;       
@@ -206,10 +207,10 @@
 IDATA VMCALL hysem_getvalue(IDATA *count, hysem_t sem) {
     IDATA status;
     
-    status = hymutex_lock(sem->mutex);
+    status = hymutex_lock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
     *count = sem->count;
-    status = hymutex_unlock(sem->mutex);
+    status = hymutex_unlock(&sem->mutex);
     if (status != TM_ERROR_NONE) return status;
 
     return TM_ERROR_NONE;      
@@ -228,14 +229,8 @@
  * @see hysem_init, hysem_wait, hysem_post
  */
 IDATA VMCALL hysem_destroy(hysem_t sem) {
-    apr_status_t apr_status;
-    apr_pool_t *pool = sem->pool;
-    if (pool != get_local_pool()) {
-        return local_pool_cleanup_register(hysem_destroy, sem);
-    }
-    apr_status=apr_thread_mutex_destroy((apr_thread_mutex_t*)sem->mutex);
-    if (apr_status != APR_SUCCESS) return CONVERT_ERROR(apr_status);
-    apr_status=apr_thread_cond_destroy((apr_thread_cond_t*)sem->condition);
-    // apr_pool_free(pool, sem);
-    return CONVERT_ERROR(apr_status);;
+    hymutex_destroy(&sem->mutex);
+    hycond_destroy(&sem->condition);
+    free(sem);
+    return TM_ERROR_NONE;
 }

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_suspend.c Tue Mar 20 09:55:17 2007
@@ -201,7 +201,7 @@
                 
     apr_atomic_inc32((apr_uint32_t *)&(thread->suspend_request));
 
-    apr_thread_yield_other(thread->os_handle);
+    os_thread_yield_other(thread->os_handle);
 
     TRACE(("TM: suspend request sent: %p request count: %d",thread , thread->suspend_request));
 }

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?view=diff&rev=520478&r1=520477&r2=520478
==============================================================================
--- 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 Mar 20 09:55:17 2007
@@ -139,7 +139,7 @@
     IDATA status;
     // trylock used to prevent cyclic suspend deadlock
     // the java_monitor_enter calls safe_point between attempts.
-    /*status = hymutex_trylock(TM_LOCK);
+    /*status = hymutex_trylock(&TM_LOCK);
     if (status !=TM_ERROR_NONE) {
         return status;
     }*/
@@ -151,7 +151,7 @@
     owner = hythread_get_thread(lock_id);
     TRACE(("Unreserved other %d \n", ++unreserve_count/*, vm_get_object_class_name(lockword_ptr-1)*/));
     if (!IS_RESERVED(lockword) || IS_FAT_LOCK(lockword)) {
-        // hymutex_unlock(TM_LOCK);
+        // hymutex_unlock(&TM_LOCK);
         return TM_ERROR_NONE;
     }
     // suspend owner 
@@ -186,11 +186,11 @@
 
     // resume owner
     if (owner) {
-        apr_thread_yield_other(owner->os_handle);
+        os_thread_yield_other(owner->os_handle);
         hythread_resume(owner);
     }
 
-    /* status = hymutex_unlock(TM_LOCK);*/
+    /* status = hymutex_unlock(&TM_LOCK);*/
 
     // Gregory - This lock, right after it was unreserved, may be
     // inflated by another thread and therefore instead of recursion
@@ -561,12 +561,12 @@
     IDATA fat_monitor_id;
     I_32 lockword;
     int i;
-    status=hymutex_lock(FAT_MONITOR_TABLE_LOCK);
+    status=hymutex_lock(&FAT_MONITOR_TABLE_LOCK);
     assert(status == TM_ERROR_NONE);
     TRACE(("inflate tmj%d\n", ++inflate_count));
     lockword = *lockword_ptr;
     if (IS_FAT_LOCK (lockword)) {
-        status = hymutex_unlock(FAT_MONITOR_TABLE_LOCK);
+        status = hymutex_unlock(&FAT_MONITOR_TABLE_LOCK);
         assert(status == TM_ERROR_NONE);
         return locktable_get_fat_monitor(FAT_LOCK_ID(lockword));
     }
@@ -587,7 +587,7 @@
     assert(status == TM_ERROR_NONE);  
     status = hythread_monitor_enter(fat_monitor);
     if (status != TM_ERROR_NONE) {
-        hymutex_unlock(FAT_MONITOR_TABLE_LOCK);
+        hymutex_unlock(&FAT_MONITOR_TABLE_LOCK);
         return NULL;
     } 
     
@@ -603,7 +603,7 @@
     TRACE(("FAT ID : 0x%x", *lockword_ptr));
     fat_monitor->inflate_count++;
     fat_monitor->inflate_owner=tm_self_tls;
-    status=hymutex_unlock(FAT_MONITOR_TABLE_LOCK);
+    status=hymutex_unlock(&FAT_MONITOR_TABLE_LOCK);
     assert(status == TM_ERROR_NONE);
 #ifdef LOCK_RESERVATION
     assert(!IS_RESERVED(*lockword_ptr));



Mime
View raw message