#3182 closed defect (fixed)

CLOCK_REALTIME timeout implementation is not POSIX compliant

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 5.1
Component: posix Version:
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by Sebastian Huber)

Changes of the CLOCK_REALTIME must trigger absolute timeouts. This is not the case. There is no test for this in RTEMS.

Change History (30)

comment:1 Changed on Oct 12, 2017 at 5:34:48 PM by Joel Sherrill

I think this only can be used via clock_nanosleep() or a timeout on a condition variable.
Do both not wakeup after a time change on CLOCK_REALTIME?

Are there tests for this?

comment:3 Changed on Oct 13, 2017 at 8:08:28 AM by Sebastian Huber

Description: modified (diff)

comment:4 Changed on Oct 17, 2017 at 6:31:01 AM by Sebastian Huber <sebastian.huber@…>

In bf2a53d2/rtems:

score: Rename watchdog variants

Rename PER_CPU_WATCHDOG_RELATIVE in PER_CPU_WATCHDOG_MONOTONIC to
highlight the corresponding POSIX CLOCK_MONOTONIC.

Rename PER_CPU_WATCHDOG_ABSOLUTE in PER_CPU_WATCHDOG_REALTIME to
highlight the corresponding POSIX CLOCK_REALTIME.

Update #3117.
Update #3182.

comment:5 Changed on Oct 17, 2017 at 6:31:14 AM by Sebastian Huber <sebastian.huber@…>

In 91ce012c/rtems:

score: Rename _Watchdog_Per_CPU_insert_monotonic()

Rename _Watchdog_Per_CPU_insert_monotonic() in
_Watchdog_Per_CPU_insert_ticks().

Update #3117.
Update #3182.

comment:6 Changed on Oct 17, 2017 at 11:57:07 AM by Sebastian Huber <sebastian.huber@…>

In 9a583a9/rtems-libbsd:

SLEEPQUEUE(9): Update due to API changes

Update #3117.
Update #3182.

comment:7 Changed on Oct 19, 2017 at 12:47:54 PM by Sebastian Huber

According to POSIX we have for clock_nanosleep():

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html

"If, at the time of the call, the time value specified by rqtp is less than or equal to the time value of the specified clock, then clock_nanosleep() shall return immediately and the calling process shall not be suspended."

Would it be all right to perform a sched_yield() in this case? This would make the implementation of the thread queue enqueue a bit easier.

comment:8 Changed on Oct 19, 2017 at 1:03:51 PM by Joel Sherrill

I think having a time in the past yield is a good solution. Just add it to the documentation in the right spots.

comment:9 Changed on Oct 19, 2017 at 1:06:45 PM by Sebastian Huber

A yield may lead to a pre-emption. I am not sure if this is all right with respect to the "return immediately and the calling process shall not be suspended".

comment:10 Changed on Oct 19, 2017 at 1:40:08 PM by Sebastian Huber

Why is nanosleep() not implemented as clock_nanosleep(CLOCK_REALTIME, 0, rqtp, rmtp)?

comment:11 Changed on Oct 19, 2017 at 1:44:02 PM by Joel Sherrill

History. nanosleep has been there much longer.

comment:12 Changed on Oct 24, 2017 at 8:20:14 AM by Sebastian Huber <sebastian.huber@…>

In d85c94c0/rtems:

psxclockrealtime01: New test

Update #3182.

comment:13 Changed on Oct 24, 2017 at 8:20:25 AM by Sebastian Huber <sebastian.huber@…>

In 02878626/rtems:

score: Add _Thread_Add_timeout_ticks()

Replace _Thread_Timer_insert_monotonic() with
_Thread_Add_timeout_ticks().

Update #3117.
Update #3182.

comment:14 Changed on Oct 24, 2017 at 8:20:37 AM by Sebastian Huber <sebastian.huber@…>

In 27cfe7c/rtems:

score: Add _Watchdog_Ticks_per_second

This value is frequently used. Avoid the function call overhead and the
integer division at run-time.

Update #3117.
Update #3182.

comment:15 Changed on Oct 24, 2017 at 8:20:49 AM by Sebastian Huber <sebastian.huber@…>

In e0dc6ef/rtems:

rtems: Simplify RTEMS_MILLISECONDS_TO_MICROSECONDS

Remove the cast so that it can be used in C pre-processor directives.

Update #3117.
Update #3182.

comment:16 Changed on Oct 24, 2017 at 8:21:01 AM by Sebastian Huber <sebastian.huber@…>

In 381ef5c/rtems:

confdefs: Warn about problematic ticks per second

A non-integer clock ticks per second value may lead to inaccurate time
format conversions.

Update #3117.
Update #3182.

comment:17 Changed on Oct 24, 2017 at 8:21:13 AM by Sebastian Huber <sebastian.huber@…>

In ecef3698/rtems:

score: Rename _Watchdog_Ticks_from_*()

Rename _Watchdog_Ticks_from_*() to _Watchdog_Realtime_from_*().

This highlights that these routines are used for the CLOCK_REALTIME
watchdogs (in contrast to CLOCK_MONOTONIC).

Update #3117.
Update #3182.

comment:18 Changed on Oct 24, 2017 at 8:21:25 AM by Sebastian Huber <sebastian.huber@…>

In adaf5c23/rtems:

score: _Watchdog_Is_far_future_realtime_timespec()

Update #3117.
Update #3182.

comment:19 Changed on Oct 24, 2017 at 8:21:36 AM by Sebastian Huber <sebastian.huber@…>

In d16d07f/rtems:

score: Add _Watchdog_Is_valid_interval_timespec()

Update #3117.
Update #3182.

comment:20 Changed on Oct 24, 2017 at 8:21:48 AM by Sebastian Huber <sebastian.huber@…>

In 7ed377b/rtems:

score: _Watchdog_Is_far_future_monotonic_timespec

Update #3117.
Update #3182.

comment:21 Changed on Oct 24, 2017 at 8:22:00 AM by Sebastian Huber <sebastian.huber@…>

In cea5ff7/rtems:

score: Add _Watchdog_Nanoseconds_per_tick

Move it from the configuration to a separate variable.

Update #3117.
Update #3182.

comment:22 Changed on Oct 24, 2017 at 8:22:12 AM by Sebastian Huber <sebastian.huber@…>

In b13ec80/rtems:

score: Add _Watchdog_Monotonic_from_timespec()

Update #3117.
Update #3182.

comment:23 Changed on Oct 24, 2017 at 8:22:24 AM by Sebastian Huber <sebastian.huber@…>

In 5747962/rtems:

score: _Watchdog_Per_CPU_lazy_insert_monotonic()

Update #3117.
Update #3182.

comment:24 Changed on Oct 24, 2017 at 8:22:36 AM by Sebastian Huber <sebastian.huber@…>

In 6de1f92/rtems:

score: Add _Thread_Continue()

Update #3117.
Update #3182.

comment:25 Changed on Oct 24, 2017 at 8:22:48 AM by Sebastian Huber <sebastian.huber@…>

In 1666ffe5/rtems:

score: Rename function threadq support function

Rename _Thread_queue_Context_set_do_nothing_enqueue_callout() into
_Thread_queue_Context_set_enqueue_do_nothing_extra(). More
_Thread_queue_Context_set_enqueue_*() functions will follow.

Update #3117.
Update #3182.

comment:26 Changed on Oct 24, 2017 at 8:23:00 AM by Sebastian Huber <sebastian.huber@…>

In c3105894/rtems:

score: Move thread queue timeout handling

Update #3117.
Update #3182.

comment:27 Changed on Oct 25, 2017 at 5:54:30 AM by Sebastian Huber <sebastian.huber@…>

Resolution: fixed
Status: assignedclosed

In c5161ee/rtems-docs:

posix-users: Clarify timed operation errors

Close #3182.

comment:28 Changed on Nov 9, 2017 at 6:27:14 AM by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

comment:29 Changed on Mar 22, 2018 at 7:43:06 AM by Sebastian Huber <sebastian.huber@…>

In 3da2f471/rtems:

mpci: Update due to thread queue API changes

Update #3117.
Update #3182.

comment:30 Changed on Mar 22, 2018 at 8:06:14 AM by Sebastian Huber <sebastian.huber@…>

In 7353422f/rtems:

mpci: Fix _MPCI_Enqueue_callout()

Update #3117.
Update #3182.

Note: See TracTickets for help on using tickets.