[vmkit-commits] [vmkit] r102861 - /vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun May 2 02:30:17 PDT 2010
Author: geoffray
Date: Sun May 2 04:30:17 2010
New Revision: 102861
URL: http://llvm.org/viewvc/llvm-project?rev=102861&view=rev
Log:
Fix bug in timedwait.
Modified:
vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
Modified: vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp?rev=102861&r1=102860&r2=102861&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctlock.cpp Sun May 2 04:30:17 2010
@@ -142,7 +142,7 @@
}
void Cond::wait(Lock* l) {
-
+ assert(l->selfOwner());
int n = l->unsafeUnlock();
Thread* th = Thread::get();
@@ -159,15 +159,19 @@
pthread_cond_signal((pthread_cond_t*)&internalCond);
}
-int Cond::timedWait(Lock* l, struct timeval *ref) {
-
+#define BILLION 1000000000
+int Cond::timedWait(Lock* l, struct timeval *ref) {
struct timespec timeout;
- struct timeval now;
- struct timezone tz;
- gettimeofday(&now, &tz);
+ struct timeval now;
+ gettimeofday(&now, NULL);
timeout.tv_sec = now.tv_sec + ref->tv_sec;
- timeout.tv_nsec = now.tv_usec + ref->tv_usec;
+ timeout.tv_nsec = (now.tv_usec + ref->tv_usec) * 1000;
+ if (timeout.tv_nsec > BILLION) {
+ timeout.tv_sec++;
+ timeout.tv_nsec -= BILLION;
+ }
+ assert(l->selfOwner());
int n = l->unsafeUnlock();
Thread* th = Thread::get();
More information about the vmkit-commits
mailing list