harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r594171 - /harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
Date Mon, 12 Nov 2007 15:11:36 GMT
Author: gshimansky
Date: Mon Nov 12 07:11:36 2007
New Revision: 594171

URL: http://svn.apache.org/viewvc?rev=594171&view=rev
Log:
Applied patch from HARMONY-5106
[drlvm][thread] os_thread_yield_other() works incorrectly on Linux


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

Modified: harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c?rev=594171&r1=594170&r2=594171&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/thread/src/linux/os_thread.c Mon Nov 12 07:11:36 2007
@@ -184,6 +184,24 @@
 }
 
 /**
+ * Calculates absolute time in future for sem_timedwait timeout.
+ * @param ptime The pointer to time structure to fill
+ * @param delay Desired timeout in ns; not greater than 10^9 (1s)
+ */
+static inline __attribute__((always_inline))
+void get_exceed_time(struct timespec* ptime, long delay)
+{
+    clock_gettime(CLOCK_REALTIME, ptime);
+
+    ptime->tv_nsec += delay;
+    if (ptime->tv_nsec >= 1000000000L) // overflow
+    {
+        ptime->tv_nsec -= 1000000000L;
+        ++ptime->tv_sec;
+    }
+}
+
+/**
  * Sends a signal to a thread to make sure thread's write
  * buffers are flushed.
  */
@@ -192,8 +210,7 @@
     struct timespec timeout;
     int r;
 
-    timeout.tv_sec = 0;
-    timeout.tv_nsec = 1000000;
+    get_exceed_time(&timeout, 1000000L);
 
     pthread_mutex_lock(&yield_other_mutex);
 



Mime
View raw message