diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index 3e04690a5b..f1eefd4b3d 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -25,9 +25,16 @@ extern "C" { #define B_INFINITE_TIMEOUT (9223372036854775807LL) enum { - B_TIMEOUT = 8, /* relative timeout */ - B_RELATIVE_TIMEOUT = 8, /* fails after a relative timeout with B_WOULD_BLOCK */ - B_ABSOLUTE_TIMEOUT = 16 /* fails after an absolute timeout with B_WOULD BLOCK */ + B_TIMEOUT = 0x8, /* relative timeout */ + B_RELATIVE_TIMEOUT = 0x8, /* fails after a relative timeout + with B_TIMED_OUT */ + B_ABSOLUTE_TIMEOUT = 0x10, /* fails after an absolute timeout + with B_TIMED_OUT */ + + /* experimental Haiku only API */ + B_TIMEOUT_REAL_TIME_BASE = 0x40, + B_ABSOLUTE_REAL_TIME_TIMEOUT = B_ABSOLUTE_TIMEOUT + | B_TIMEOUT_REAL_TIME_BASE }; /*-------------------------------------------------------------*/ diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 56bc0adf8d..fca78b9e29 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -2271,8 +2272,14 @@ thread_block_with_timeout_locked(uint32 timeoutFlags, bigtime_t timeout) // avoids nasty race conditions and deadlock problems that could // otherwise occur between our cancel_timer() and a concurrently // executing thread_block_timeout(). - uint32 timerFlags = (timeoutFlags & B_RELATIVE_TIMEOUT) - ? B_ONE_SHOT_RELATIVE_TIMER : B_ONE_SHOT_ABSOLUTE_TIMER; + uint32 timerFlags; + if ((timeoutFlags & B_RELATIVE_TIMEOUT) != 0) { + timerFlags = B_ONE_SHOT_RELATIVE_TIMER; + } else { + timerFlags = B_ONE_SHOT_ABSOLUTE_TIMER; + if ((timeoutFlags & B_TIMEOUT_REAL_TIME_BASE) != 0) + timeout -= rtc_boot_time(); + } timerFlags |= B_TIMER_ACQUIRE_THREAD_LOCK; // install the timer