[PATCH] posix: Fix relative CLOCK_REALTIME sleep
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Aug 1 07:22:18 UTC 2022
A relative CLOCK_REALTIME time out shall not be affected by CLOCK_REALTIME
changes through clock_settime(). Since our CLOCK_REALTIME is basically just
CLOCK_MONOTONIC plus an offset, we can simply use the CLOCK_MONOTONIC watchdog
for relative CLOCK_REALTIME time outs.
Update #4690.
---
cpukit/posix/src/clocknanosleep.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cpukit/posix/src/clocknanosleep.c b/cpukit/posix/src/clocknanosleep.c
index 3fa890fecd..bfa8ef7975 100644
--- a/cpukit/posix/src/clocknanosleep.c
+++ b/cpukit/posix/src/clocknanosleep.c
@@ -82,6 +82,15 @@ int clock_nanosleep(
rmtp = NULL;
} else {
absolute = false;
+
+ /*
+ * A relative CLOCK_REALTIME time out shall not be affected by
+ * CLOCK_REALTIME changes through clock_settime(). Since our
+ * CLOCK_REALTIME is basically just CLOCK_MONOTONIC plus an offset, we can
+ * simply use the CLOCK_MONOTONIC watchdog for relative CLOCK_REALTIME time
+ * outs.
+ */
+ clock_id = CLOCK_MONOTONIC;
}
if ( clock_id == CLOCK_REALTIME ) {
--
2.35.3
More information about the devel
mailing list