From a636a33926ec5b330d09ae0cfa0c60363450f2f7 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 10 May 2008 21:44:03 +0000 Subject: [PATCH] Use the new B_ABSOLUTE_REAL_TIME_TIMEOUT. Fixes pthread_cond_timedwait() and pthread_mutex_timedlock() which were waiting system time relative although their timeout parameter is Epoch relative. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25435 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/posix/realtime_sem.cpp | 6 ++---- src/system/libroot/posix/pthread/pthread_cond.c | 3 ++- src/system/libroot/posix/pthread/pthread_mutex.c | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/posix/realtime_sem.cpp b/src/system/kernel/posix/realtime_sem.cpp index 054418125f..3954214f5f 100644 --- a/src/system/kernel/posix/realtime_sem.cpp +++ b/src/system/kernel/posix/realtime_sem.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -740,9 +739,8 @@ struct realtime_sem_context { } else if (timeout == B_INFINITE_TIMEOUT) { error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT, 0); } else { - error = acquire_sem_etc(id, 1, B_CAN_INTERRUPT | B_ABSOLUTE_TIMEOUT, - timeout - rtc_boot_time()); - // The given absolute timeout is relative to the Epoch. + error = acquire_sem_etc(id, 1, + B_CAN_INTERRUPT | B_ABSOLUTE_REAL_TIME_TIMEOUT, timeout); } return error == B_BAD_SEM_ID ? B_BAD_VALUE : error; diff --git a/src/system/libroot/posix/pthread/pthread_cond.c b/src/system/libroot/posix/pthread/pthread_cond.c index 9f53cbadea..211b958017 100644 --- a/src/system/libroot/posix/pthread/pthread_cond.c +++ b/src/system/libroot/posix/pthread/pthread_cond.c @@ -108,7 +108,8 @@ cond_wait(pthread_cond *cond, pthread_mutex_t *_mutex, bigtime_t timeout) do { status = acquire_sem_etc(cond->sem, 1, - timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); + timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_REAL_TIME_TIMEOUT, + timeout); } while (status == B_OK && atomic_get(&cond->event_counter) == event); pthread_mutex_lock(_mutex); diff --git a/src/system/libroot/posix/pthread/pthread_mutex.c b/src/system/libroot/posix/pthread/pthread_mutex.c index 044b2034c9..d03fd6d4b6 100644 --- a/src/system/libroot/posix/pthread/pthread_mutex.c +++ b/src/system/libroot/posix/pthread/pthread_mutex.c @@ -147,7 +147,9 @@ mutex_lock(pthread_mutex *mutex, bigtime_t timeout) if (!mutex->attr.process_shared || atomic_add(&mutex->count, 1) > 0) { // this mutex is already locked by someone else, so we need // to wait - status = acquire_sem_etc(mutex->sem, 1, timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_TIMEOUT, timeout); + status = acquire_sem_etc(mutex->sem, 1, + timeout == B_INFINITE_TIMEOUT ? 0 : B_ABSOLUTE_REAL_TIME_TIMEOUT, + timeout); } if (status == B_OK) {