From c31058947491ca319c901040219be39e4f8155b6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 19 Oct 2017 13:47:57 +0200 Subject: score: Move thread queue timeout handling Update #3117. Update #3182. --- cpukit/posix/src/sigtimedwait.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'cpukit/posix/src/sigtimedwait.c') diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c index 70170bf2f7..a0e18adef0 100644 --- a/cpukit/posix/src/sigtimedwait.c +++ b/cpukit/posix/src/sigtimedwait.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include static int _POSIX_signals_Get_lowest( @@ -89,20 +91,24 @@ int sigtimedwait( * in the Open Group specification. */ - if ( timeout ) { - Watchdog_Interval interval; + if ( timeout != NULL ) { + struct timespec end; - if ( !_Timespec_Is_valid( timeout ) ) - rtems_set_errno_and_return_minus_one( EINVAL ); + if ( !_Watchdog_Is_valid_interval_timespec( timeout ) ) { + return EINVAL; + } - interval = _Timespec_To_ticks( timeout ); + _TOD_Get_zero_based_uptime_as_timespec( &end ); - if ( !interval ) - rtems_set_errno_and_return_minus_one( EINVAL ); + /* In case this overflows, then the enqueue callout will reject it */ + _Timespec_Add_to( &end, timeout ); - _Thread_queue_Context_set_relative_timeout( &queue_context, interval ); + _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec( + &queue_context, + &end + ); } else { - _Thread_queue_Context_set_no_timeout( &queue_context ); + _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); } /* @@ -160,7 +166,6 @@ int sigtimedwait( &queue_context, STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL ); - _Thread_queue_Context_set_enqueue_do_nothing_extra( &queue_context ); _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue.Queue, POSIX_SIGNALS_TQ_OPERATIONS, -- cgit v1.2.3