Added timeout constant B_ABSOLUTE_REAL_TIME_TIMEOUT which specifies a
timeout relative to the Epoch. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25434 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+10
-3
@@ -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
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <kimage.h>
|
||||
#include <kscheduler.h>
|
||||
#include <ksignal.h>
|
||||
#include <real_time_clock.h>
|
||||
#include <smp.h>
|
||||
#include <syscalls.h>
|
||||
#include <syscall_restart.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user