You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by wj...@apache.org on 2006/12/08 13:57:43 UTC

svn commit: r483976 - /harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c

Author: wjwashburn
Date: Fri Dec  8 04:57:42 2006
New Revision: 483976

URL: http://svn.apache.org/viewvc?view=rev&rev=483976
Log:
Harmony-1951, patch number 4 (prevents spurious interrupts)
although java apps must be written to survive spurious interrupts, it was
decided to filter them out in DRLVM to make debugging simpler
build and build test run on windows 32 and linux 32 w/ gcc 4.0.2


Modified:
    harmony/enhanced/drlvm/trunk/vm/thread/src/thread_native_fat_monitor.c

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=483976&r1=483975&r2=483976
==============================================================================
--- 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 Fri Dec  8 04:57:42 2006
@@ -67,6 +67,7 @@
     mon->flags = flags;
     mon->name  = name;
     mon->owner = 0;
+    mon->notify_flag = 0;
 
         *mon_ptr = mon;
     return TM_ERROR_NONE;
@@ -205,8 +206,35 @@
     self->state |= TM_THREAD_STATE_IN_MONITOR_WAIT;
     hymutex_unlock(self->mutex);
 
-    status =  condvar_wait_impl(mon_ptr->condition, mon_ptr->mutex, ms, nano, interruptable);
-
+    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);
+        if (status != TM_ERROR_NONE
+                || mon_ptr->notify_flag || hythread_interrupted(self))
+            break;
+        // we should not change ms and nano if both are 0 (meaning "no timeout")
+        if (ms || nano) {
+            apr_interval_time_t elapsed;
+            elapsed = apr_time_now() - start; // microseconds
+            nano -= (IDATA)((elapsed % 1000) * 1000);
+            if (nano < 0) {
+                ms -= elapsed/1000 + 1;
+                nano += 1000000;
+            } else {
+                ms -= elapsed/1000;
+            }
+            if (ms < 0) {
+                assert(status == TM_ERROR_NONE);
+                status = TM_ERROR_TIMEOUT;
+                break;
+            }
+            assert(0 <= nano && nano < 1000000);
+        }
+    } while (1);
+    if (mon_ptr->notify_flag)
+        mon_ptr->notify_flag -= 1;
     hymutex_lock(self->mutex);
     self->state &= ~TM_THREAD_STATE_IN_MONITOR_WAIT;
     self->current_condition = NULL;
@@ -321,7 +349,8 @@
         mon_ptr->notify_flag=1;
         return TM_ERROR_NONE;
 #else
-        return hycond_notify_all(mon_ptr->condition);   
+    mon_ptr->notify_flag = mon_ptr->wait_count;
+    return hycond_notify_all(mon_ptr->condition);
 #endif
 }
 
@@ -347,7 +376,9 @@
         mon_ptr->notify_flag=1;
         return TM_ERROR_NONE;
 #else
-        return hycond_notify(mon_ptr->condition);   
+    if (mon_ptr->notify_flag < mon_ptr->wait_count)
+        mon_ptr->notify_flag += 1;
+    return hycond_notify(mon_ptr->condition);
 #endif
 }