harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r454416 - in /incubator/harmony/enhanced/drlvm/trunk/vm: include/open/jthread.h thread/src/thread_java_park.c thread/src/thread_native_condvar.c vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp
Date Mon, 09 Oct 2006 16:19:20 GMT
Author: geirm
Date: Mon Oct  9 09:19:19 2006
New Revision: 454416

URL: http://svn.apache.org/viewvc?view=rev&rev=454416
Log:
HARMONY-1383

Preparing a patch for juc integration I found some regressions after integration of ThreadManager.
I used a DL's unit tests and the attached tests were extracted from them.

To reproduce:
1. Put LockSupport.java (attached) in vm/vmcore/src/kernel_classes/javasrc/java/util/concurrent/locks/
2. build DRLVM (or kernel classes)
3. comment "concurrent.jar" in lib/bootclasspath.properties
4. Compile and run the tests attached.

- TestParkUntil - hangs (looks like it does not calculate deadline)
- TestIntAfterPark - shows that "interrupted" flag is not set after interruption of a parked
thread.


tests pass now

Ubuntu 6, smoke,c-unit, ~kernel


Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_park.c
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h?view=diff&rev=454416&r1=454415&r2=454416
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/include/open/jthread.h Mon Oct  9 09:19:19 2006
@@ -177,6 +177,7 @@
  IDATA jthread_park();
  IDATA jthread_timed_park(jlong millis, jint nanos);
  IDATA jthread_unpark(jthread thread);
+ IDATA jthread_park_until(jlong milis);
 
 //@}
 /** @name Suspension

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_park.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_park.c?view=diff&rev=454416&r1=454415&r2=454416
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_park.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_java_park.c Mon Oct  9 09:19:19
2006
@@ -25,6 +25,7 @@
  * @brief Java thread park/unpark functions
  */
 
+#include <apr_time.h>
 #include <open/jthread.h>
 #include <open/hythread_ext.h>
 #include "thread_private.h"
@@ -79,4 +80,20 @@
     hythread_unpark(tm_native_thread);
     
     return TM_ERROR_NONE;
+}
+
+/**
+ * Parks the current thread until the specified deadline
+ *
+ * Stops the current thread from executing until it is unparked, interrupted,
+ * or until the specified dealine.
+ * Unlike wait or sleep, the interrupted flag is NOT cleared by this API.
+ *
+ * @param[in] millis absolute time in milliseconds to wait until
+ * @sa java.util.concurrent.locks.LockSupport.parkUntil() 
+ */
+IDATA VMCALL jthread_park_until(jlong millis) {
+    jlong delta = millis - apr_time_now()/1000;
+    if (delta <= 0) return TM_ERROR_NONE;
+    return hythread_park((I_64)delta, 0);
 }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c?view=diff&rev=454416&r1=454415&r2=454416
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_condvar.c Mon Oct 
9 09:19:19 2006
@@ -59,8 +59,6 @@
 
         // check interrupted flag
     if (interruptable && (this_thread->state & TM_THREAD_STATE_INTERRUPTED))
{
-        // clean interrupted flag
-        this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED);
                 return TM_ERROR_INTERRUPT;
     }
 
@@ -76,8 +74,6 @@
    
     // check interrupted flag
     if (interruptable &&  (this_thread->state & TM_THREAD_STATE_INTERRUPTED))
{
-        // clean interrupted flag
-        this_thread->state &= (~TM_THREAD_STATE_INTERRUPTED);
                 return TM_ERROR_INTERRUPT;
     }
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp?view=diff&rev=454416&r1=454415&r2=454416
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/native/java_util_concurrent_locks_LockSupport.cpp
Mon Oct  9 09:19:19 2006
@@ -29,6 +29,7 @@
  * Method: java.util.concurrent.locks.LockSupport.unpark(Ljava/lang/Thread;)V
  */
 JNIEXPORT void JNICALL Java_java_util_concurrent_locks_LockSupport_unpark (JNIEnv *jenv,
jclass, jobject thread) {
+    if (!thread) return;
     jthread_unpark(thread);
 }
 
@@ -59,8 +60,7 @@
 /*
  * Method: java.util.concurrent.locks.LockSupport.parkUntil(J)V
  */
-JNIEXPORT void JNICALL Java_java_util_concurrent_locks_LockSupport_parkUntil(JNIEnv * UNREF
jenv, jclass UNREF thread, jlong milis) {
-    //FIXME integration should be parkUntil
-    jthread_timed_park((jlong)milis, 0);
+JNIEXPORT void JNICALL Java_java_util_concurrent_locks_LockSupport_parkUntil(JNIEnv * UNREF
jenv, jclass UNREF thread, jlong millis) {
+    jthread_park_until((jlong)millis);
 }
 



Mime
View raw message