diff options
Diffstat (limited to 'cpukit/include')
-rw-r--r-- | cpukit/include/rtems/score/threadq.h | 9 | ||||
-rw-r--r-- | cpukit/include/rtems/score/threadqimpl.h | 36 | ||||
-rw-r--r-- | cpukit/include/rtems/score/watchdogimpl.h | 16 |
3 files changed, 48 insertions, 13 deletions
diff --git a/cpukit/include/rtems/score/threadq.h b/cpukit/include/rtems/score/threadq.h index 5234019b81..10476888d4 100644 --- a/cpukit/include/rtems/score/threadq.h +++ b/cpukit/include/rtems/score/threadq.h @@ -214,7 +214,8 @@ struct Thread_queue_Context { * callout must be used to install the thread watchdog for timeout handling. * * @see _Thread_queue_Enqueue_do_nothing_extra(). - * _Thread_queue_Add_timeout_ticks(), and + * _Thread_queue_Add_timeout_ticks(), + * _Thread_queue_Add_timeout_monotonic_timespec(), and * _Thread_queue_Add_timeout_realtime_timespec(). */ Thread_queue_Enqueue_callout enqueue_callout; @@ -236,6 +237,12 @@ struct Thread_queue_Context { const void *arg; } Timeout; + /** + * @brief If this member is true, the timeout shall be absolute, otherwise it + * shall be relative to the current time of the clock. + */ + bool timeout_absolute; + #if defined(RTEMS_SMP) /** * @brief Representation of a thread queue path from a start thread queue to diff --git a/cpukit/include/rtems/score/threadqimpl.h b/cpukit/include/rtems/score/threadqimpl.h index ca59de9e31..7b00de009d 100644 --- a/cpukit/include/rtems/score/threadqimpl.h +++ b/cpukit/include/rtems/score/threadqimpl.h @@ -267,41 +267,53 @@ _Thread_queue_Context_set_enqueue_timeout_ticks( } /** - * @brief Sets the enqueue callout to add an absolute monotonic timeout in - * timespec format. + * @brief Sets the enqueue callout to add a timeout in timespec format using + * CLOCK_MONOTONIC. * - * @param[out] queue_context The thread queue context. - * @param abstime The absolute monotonic timeout. + * @param[out] queue_context is the thread queue context. + * + * @param timeout is the absolute or relative timeout. + * + * @param absolute is true, if the timeout shall be absolute, otherwise it + * shall be relative to the current time of the clock. * * @see _Thread_queue_Enqueue(). */ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( Thread_queue_Context *queue_context, - const struct timespec *abstime + const struct timespec *timeout, + bool absolute ) { - queue_context->Timeout.arg = abstime; + queue_context->Timeout.arg = timeout; + queue_context->timeout_absolute = absolute; queue_context->enqueue_callout = _Thread_queue_Add_timeout_monotonic_timespec; } /** - * @brief Sets the enqueue callout to add an absolute realtime timeout in - * timespec format. + * @brief Sets the enqueue callout to add a timeout in timespec format using + * CLOCK_REALTIME. * - * @param[out] queue_context The thread queue context. - * @param abstime The absolute realtime timeout. + * @param[out] queue_context is the thread queue context. + * + * @param timeout is the absolute or relative timeout. + * + * @param absolute is true, if the timeout shall be absolute, otherwise it + * shall be relative to the current time of the clock. * * @see _Thread_queue_Enqueue(). */ RTEMS_INLINE_ROUTINE void _Thread_queue_Context_set_enqueue_timeout_realtime_timespec( Thread_queue_Context *queue_context, - const struct timespec *abstime + const struct timespec *timeout, + bool absolute ) { - queue_context->Timeout.arg = abstime; + queue_context->Timeout.arg = timeout; + queue_context->timeout_absolute = absolute; queue_context->enqueue_callout = _Thread_queue_Add_timeout_realtime_timespec; } diff --git a/cpukit/include/rtems/score/watchdogimpl.h b/cpukit/include/rtems/score/watchdogimpl.h index a8e6de4fbe..7b364b8828 100644 --- a/cpukit/include/rtems/score/watchdogimpl.h +++ b/cpukit/include/rtems/score/watchdogimpl.h @@ -535,6 +535,22 @@ RTEMS_INLINE_ROUTINE uint64_t _Watchdog_Ticks_from_timespec( } /** + * @brief Converts the ticks to timespec. + * + * @param ticks are the ticks to convert. + * + * @param[out] ts is the timespec to return the converted ticks. + */ +RTEMS_INLINE_ROUTINE void _Watchdog_Ticks_to_timespec( + uint64_t ticks, + struct timespec *ts +) +{ + ts->tv_sec = ticks >> WATCHDOG_BITS_FOR_1E9_NANOSECONDS; + ts->tv_nsec = ticks & ( ( 1U << WATCHDOG_BITS_FOR_1E9_NANOSECONDS ) - 1 ); +} + +/** * @brief Converts the sbintime in ticks. * * @param sbt The sbintime to convert to ticks. |