[rtems commit] score: Use right clock for threadq timeouts

Sebastian Huber sebh at rtems.org
Thu Jun 23 07:14:48 UTC 2022


Module:    rtems
Branch:    master
Commit:    cd50bea678baa494640415377f7be146246ba3e4
Changeset: http://git.rtems.org/rtems/commit/?id=cd50bea678baa494640415377f7be146246ba3e4

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Jun 22 11:02:33 2022 +0200

score: Use right clock for threadq timeouts

Use CLOCK_REALTIME and CLOCK_MONOTONIC for relative thread queue timeouts
instead of CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE.  This fixes an
issue with clock_nanosleep() in combination with clock_gettime().

Close #4669.

---

 cpukit/score/src/threadqtimeout.c          |  4 ++--
 testsuites/validation/tc-clock-nanosleep.c | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/cpukit/score/src/threadqtimeout.c b/cpukit/score/src/threadqtimeout.c
index 271ea27f27..10e194f6d8 100644
--- a/cpukit/score/src/threadqtimeout.c
+++ b/cpukit/score/src/threadqtimeout.c
@@ -132,7 +132,7 @@ void _Thread_queue_Add_timeout_monotonic_timespec(
 {
   struct timespec now;
 
-  _Timecounter_Getnanouptime( &now );
+  _Timecounter_Nanouptime( &now );
   _Thread_queue_Add_timeout_timespec(
     queue,
     the_thread,
@@ -152,7 +152,7 @@ void _Thread_queue_Add_timeout_realtime_timespec(
 {
   struct timespec now;
 
-  _Timecounter_Getnanotime( &now );
+  _Timecounter_Nanotime( &now );
   _Thread_queue_Add_timeout_timespec(
     queue,
     the_thread,
diff --git a/testsuites/validation/tc-clock-nanosleep.c b/testsuites/validation/tc-clock-nanosleep.c
index 2857d8e274..2f4d439efe 100644
--- a/testsuites/validation/tc-clock-nanosleep.c
+++ b/testsuites/validation/tc-clock-nanosleep.c
@@ -325,14 +325,20 @@ static void Worker( rtems_task_argument arg )
 
   while ( true ) {
     T_scheduler_log *log;
+    uint32_t         counter;
 
     SuspendSelf();
 
     log = T_scheduler_record_4( &ctx->scheduler_log );
     T_null( log );
 
-    _Timecounter_Getnanotime( &ctx->now_realtime );
-    _Timecounter_Getnanouptime( &ctx->now_monotonic );
+    counter = GetTimecountCounter();
+    _Timecounter_Nanotime( &ctx->now_realtime );
+    SetTimecountCounter( counter );
+
+    counter = GetTimecountCounter();
+    _Timecounter_Nanouptime( &ctx->now_monotonic );
+    SetTimecountCounter( counter );
 
     ctx->status = clock_nanosleep(
       ctx->clock_id,



More information about the vc mailing list