[PATCH 1/2] posix: Fix use of clock for relative times

Gedare Bloom gedare at rtems.org
Tue May 18 16:05:10 UTC 2021


On Tue, May 18, 2021 at 7:05 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> Close #4426.
> ---
>  cpukit/posix/src/clocknanosleep.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/cpukit/posix/src/clocknanosleep.c b/cpukit/posix/src/clocknanosleep.c
> index 951268bc1f..eb7f231e86 100644
> --- a/cpukit/posix/src/clocknanosleep.c
> +++ b/cpukit/posix/src/clocknanosleep.c
> @@ -61,21 +61,17 @@ int clock_nanosleep(
>
>    if ( ( flags & TIMER_ABSTIME ) != 0 ) {
>      end = rqtp;
> -
> -    if ( clock_id == CLOCK_REALTIME ) {
> -      _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
> -        &queue_context,
> -        end
> -      );
> -    } else {
> -      _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
> -        &queue_context,
> -        end
> -      );
> -    }
>    } else {
>      _Timecounter_Nanouptime( &uptime );
Shouldn't this also be _Timecounter_Nanotime( &now) in case of using
CLOCK_REALTIME?

>      end = _Watchdog_Future_timespec( &uptime, rqtp );
> +  }
> +
> +  if ( clock_id == CLOCK_REALTIME ) {
> +    _Thread_queue_Context_set_enqueue_timeout_realtime_timespec(
> +      &queue_context,
> +      end
> +    );
> +  } else {
>      _Thread_queue_Context_set_enqueue_timeout_monotonic_timespec(
>        &queue_context,
>        end
> @@ -101,7 +97,11 @@ int clock_nanosleep(
>      if ( eno == EINTR ) {
>        struct timespec actual_end;
>
> -      _Timecounter_Nanouptime( &actual_end );
> +      if ( clock_id == CLOCK_REALTIME ) {
> +        _Timecounter_Nanotime( &actual_end );
> +      } else {
> +        _Timecounter_Nanouptime( &actual_end );
> +      }
>
>        if ( _Timespec_Less_than( &actual_end, end ) ) {
>          _Timespec_Subtract( &actual_end, end, rmtp );
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list