diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-05-18 12:50:41 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-05-18 18:47:43 +0200 |
commit | a89ecaa1a94d49ddae7753d6b83923e9d2a00486 (patch) | |
tree | 2fccf3fd6b5a82f0415b497db190fbfa582a3866 /cpukit/score/src | |
parent | posix: Fix use of clock for relative times (diff) | |
download | rtems-a89ecaa1a94d49ddae7753d6b83923e9d2a00486.tar.bz2 |
score: Simplify thread queue timeout handling
Add Thread_queue_Context::timeout_absolute to specify an absolute or
relative timeout. This avoid having to get the current time twice for
timeouts relative to the current time. It moves also functionality to
common code.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r-- | cpukit/score/src/mutex.c | 6 | ||||
-rw-r--r-- | cpukit/score/src/threadqtimeout.c | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c index 88a390f323..f7e35093b2 100644 --- a/cpukit/score/src/mutex.c +++ b/cpukit/score/src/mutex.c @@ -206,7 +206,8 @@ int _Mutex_Acquire_timed( } else { _Thread_queue_Context_set_enqueue_timeout_realtime_timespec( &queue_context, - abstime + abstime, + true ); _Mutex_Acquire_slow( mutex, owner, executing, level, &queue_context ); @@ -327,7 +328,8 @@ int _Mutex_recursive_Acquire_timed( } else { _Thread_queue_Context_set_enqueue_timeout_realtime_timespec( &queue_context, - abstime + abstime, + true ); _Mutex_Acquire_slow( &mutex->Mutex, owner, executing, level, &queue_context ); diff --git a/cpukit/score/src/threadqtimeout.c b/cpukit/score/src/threadqtimeout.c index ec8f67c93b..a3aeea43be 100644 --- a/cpukit/score/src/threadqtimeout.c +++ b/cpukit/score/src/threadqtimeout.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2016, 2017 embedded brains GmbH + * Copyright (c) 2016, 2021 embedded brains GmbH * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -55,8 +55,14 @@ static void _Thread_queue_Add_timeout_timespec( ) { const struct timespec *abstime; + struct timespec base; - abstime = queue_context->Timeout.arg; + if ( queue_context->timeout_absolute ) { + abstime = queue_context->Timeout.arg; + } else { + base = *now; + abstime = _Watchdog_Future_timespec( &base, queue_context->Timeout.arg ); + } if ( _Watchdog_Is_valid_timespec( abstime ) ) { uint64_t expire; |