Fwd: [PATCH 1/2] score: Add and use Watchdog_Clock for clock types.

Gedare Bloom gedare at rtems.org
Wed Jun 15 23:19:33 UTC 2016


For review, the below patch failed to get through the spam filter..

Clock types may be WATCHDOG_RELATIVE or WATCHDOG_ABSOLUTE
and they relate to the PER_CPU_WATCHDOG_RELATIVE/ABSOLUTE.

updates #2732
---
 cpukit/posix/src/condwaitsupp.c                 |  1 +
 cpukit/posix/src/nanosleep.c                    |  1 +
 cpukit/posix/src/sigtimedwait.c                 |  1 +
 cpukit/rtems/src/eventseize.c                   |  5 ++--
 cpukit/rtems/src/regiongetsegment.c             |  1 +
 cpukit/rtems/src/taskwakeafter.c                |  5 ++--
 cpukit/rtems/src/taskwakewhen.c                 |  5 ++--
 cpukit/score/include/rtems/score/coresemimpl.h  |  1 +
 cpukit/score/include/rtems/score/threadimpl.h   | 31 +++++++------------------
 cpukit/score/include/rtems/score/threadqimpl.h  |  5 ++++
 cpukit/score/include/rtems/score/watchdog.h     | 23 ++++++++++++++++++
 cpukit/score/include/rtems/score/watchdogimpl.h |  2 +-
 cpukit/score/src/condition.c                    |  1 +
 cpukit/score/src/corebarrierwait.c              |  1 +
 cpukit/score/src/coremsgseize.c                 |  1 +
 cpukit/score/src/coremsgsubmit.c                |  1 +
 cpukit/score/src/coremutexseize.c               |  3 +++
 cpukit/score/src/corerwlockobtainread.c         |  1 +
 cpukit/score/src/corerwlockobtainwrite.c        |  1 +
 cpukit/score/src/futex.c                        |  1 +
 cpukit/score/src/mpci.c                         |  1 +
 cpukit/score/src/mutex.c                        |  1 +
 cpukit/score/src/semaphore.c                    |  1 +
 cpukit/score/src/threadqenqueue.c               |  6 +++--
 cpukit/score/src/threadrestart.c                |  1 +
 25 files changed, 70 insertions(+), 31 deletions(-)

diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c
index ebcb3c4..08f96d1 100644
--- a/cpukit/posix/src/condwaitsupp.c
+++ b/cpukit/posix/src/condwaitsupp.c
@@ -74,6 +74,7 @@ int _POSIX_Condition_variables_Wait_support(
       executing,
       STATES_WAITING_FOR_CONDITION_VARIABLE,
       timeout,
+      WATCHDOG_RELATIVE,
       &queue_context
     );
   } else {
diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c
index e0e1b26..8fc86d6 100644
--- a/cpukit/posix/src/nanosleep.c
+++ b/cpukit/posix/src/nanosleep.c
@@ -93,6 +93,7 @@ int nanosleep(
     executing,
     STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL,
     ticks,
+    WATCHDOG_RELATIVE,
     1
   );

diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c
index 7855bb0..1bdb278 100644
--- a/cpukit/posix/src/sigtimedwait.c
+++ b/cpukit/posix/src/sigtimedwait.c
@@ -159,6 +159,7 @@ int sigtimedwait(
     executing,
     STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
     interval,
+    WATCHDOG_RELATIVE,
     &queue_context
   );

diff --git a/cpukit/rtems/src/eventseize.c b/cpukit/rtems/src/eventseize.c
index c91d308..468e066 100644
--- a/cpukit/rtems/src/eventseize.c
+++ b/cpukit/rtems/src/eventseize.c
@@ -81,11 +81,12 @@ rtems_status_code _Event_Seize(
   _Thread_Lock_release_default( executing, lock_context );

   if ( ticks ) {
-    _Thread_Timer_insert_relative(
+    _Thread_Timer_insert(
       executing,
       cpu_self,
       _Thread_Timeout,
-      ticks
+      ticks,
+      WATCHDOG_RELATIVE
     );
   }

diff --git a/cpukit/rtems/src/regiongetsegment.c
b/cpukit/rtems/src/regiongetsegment.c
index cfc6645..ec0c525 100644
--- a/cpukit/rtems/src/regiongetsegment.c
+++ b/cpukit/rtems/src/regiongetsegment.c
@@ -87,6 +87,7 @@ rtems_status_code rtems_region_get_segment(
         executing,
         STATES_WAITING_FOR_SEGMENT,
         timeout,
+        WATCHDOG_RELATIVE,
         2
       );

diff --git a/cpukit/rtems/src/taskwakeafter.c b/cpukit/rtems/src/taskwakeafter.c
index fa5f6f4..c1a8234 100644
--- a/cpukit/rtems/src/taskwakeafter.c
+++ b/cpukit/rtems/src/taskwakeafter.c
@@ -41,11 +41,12 @@ rtems_status_code rtems_task_wake_after(
     } else {
       _Thread_Set_state( executing, STATES_DELAYING );
       _Thread_Wait_flags_set( executing, THREAD_WAIT_STATE_BLOCKED );
-      _Thread_Timer_insert_relative(
+      _Thread_Timer_insert(
         executing,
         cpu_self,
         _Thread_Timeout,
-        ticks
+        ticks,
+        WATCHDOG_RELATIVE
       );
     }
   _Thread_Dispatch_enable( cpu_self );
diff --git a/cpukit/rtems/src/taskwakewhen.c b/cpukit/rtems/src/taskwakewhen.c
index 5d6d45a..6b76d3e 100644
--- a/cpukit/rtems/src/taskwakewhen.c
+++ b/cpukit/rtems/src/taskwakewhen.c
@@ -52,11 +52,12 @@ rtems_status_code rtems_task_wake_when(
     executing = _Thread_Executing;
     _Thread_Set_state( executing, STATES_WAITING_FOR_TIME );
     _Thread_Wait_flags_set( executing, THREAD_WAIT_STATE_BLOCKED );
-    _Thread_Timer_insert_absolute(
+    _Thread_Timer_insert(
       executing,
       cpu_self,
       _Thread_Timeout,
-      _Watchdog_Ticks_from_seconds( seconds )
+      _Watchdog_Ticks_from_seconds( seconds ),
+      WATCHDOG_ABSOLUTE
     );
   _Thread_Dispatch_enable( cpu_self );
   return RTEMS_SUCCESSFUL;
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h
b/cpukit/score/include/rtems/score/coresemimpl.h
index 487a91b..a562534 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -199,6 +199,7 @@ RTEMS_INLINE_ROUTINE Status_Control _CORE_semaphore_Seize(
     executing,
     STATES_WAITING_FOR_SEMAPHORE,
     timeout,
+    WATCHDOG_RELATIVE,
     queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/include/rtems/score/threadimpl.h
b/cpukit/score/include/rtems/score/threadimpl.h
index 164773a..520a194 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -1461,38 +1461,25 @@ RTEMS_INLINE_ROUTINE void _Thread_Timer_initialize(
   _Watchdog_Preinitialize( &timer->Watchdog, cpu );
 }

-RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_relative(
+RTEMS_INLINE_ROUTINE void _Thread_Timer_insert(
   Thread_Control                 *the_thread,
   Per_CPU_Control                *cpu,
   Watchdog_Service_routine_entry  routine,
-  Watchdog_Interval               ticks
+  uint64_t                        ticks,
+  Watchdog_Clock                  clock
 )
 {
   ISR_lock_Context lock_context;

   _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );

-  the_thread->Timer.header = &cpu->Watchdog.Header[
PER_CPU_WATCHDOG_RELATIVE ];
+  the_thread->Timer.header = &cpu->Watchdog.Header[ clock ];
   the_thread->Timer.Watchdog.routine = routine;
-  _Watchdog_Per_CPU_insert_relative( &the_thread->Timer.Watchdog, cpu, ticks );
-
-  _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context );
-}
-
-RTEMS_INLINE_ROUTINE void _Thread_Timer_insert_absolute(
-  Thread_Control                 *the_thread,
-  Per_CPU_Control                *cpu,
-  Watchdog_Service_routine_entry  routine,
-  uint64_t                        expire
-)
-{
-  ISR_lock_Context lock_context;
-
-  _ISR_lock_ISR_disable_and_acquire( &the_thread->Timer.Lock, &lock_context );
-
-  the_thread->Timer.header = &cpu->Watchdog.Header[
PER_CPU_WATCHDOG_ABSOLUTE ];
-  the_thread->Timer.Watchdog.routine = routine;
-  _Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog,
cpu, expire );
+  if ( clock == WATCHDOG_RELATIVE ) {
+    _Watchdog_Per_CPU_insert_relative( &the_thread->Timer.Watchdog,
cpu, ticks );
+  } else {
+    _Watchdog_Per_CPU_insert_absolute( &the_thread->Timer.Watchdog,
cpu, ticks );
+  }

   _ISR_lock_Release_and_ISR_enable( &the_thread->Timer.Lock, &lock_context );
 }
diff --git a/cpukit/score/include/rtems/score/threadqimpl.h
b/cpukit/score/include/rtems/score/threadqimpl.h
index 73d4de2..f59a334 100644
--- a/cpukit/score/include/rtems/score/threadqimpl.h
+++ b/cpukit/score/include/rtems/score/threadqimpl.h
@@ -349,6 +349,7 @@ Thread_Control *_Thread_queue_Do_dequeue(
  *       executing,
  *       STATES_WAITING_FOR_MUTEX,
  *       WATCHDOG_NO_TIMEOUT,
+ *       WATCHDOG_RELATIVE,
  *       0,
  *       &queue_context
  *     );
@@ -362,6 +363,7 @@ Thread_Control *_Thread_queue_Do_dequeue(
  * @param[in] state The new state of the thread.
  * @param[in] timeout Interval to wait.  Use WATCHDOG_NO_TIMEOUT to block
  * potentially forever.
+ * @param[in] clock The kind of clock used for the interval.
  * @param[in] queue_context The thread queue context of the lock acquire.
  */
 void _Thread_queue_Enqueue_critical(
@@ -370,6 +372,7 @@ void _Thread_queue_Enqueue_critical(
   Thread_Control                *the_thread,
   States_Control                 state,
   Watchdog_Interval              timeout,
+  Watchdog_Clock                 clock,
   Thread_queue_Context          *queue_context
 );

@@ -383,6 +386,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
   Thread_Control                *the_thread,
   States_Control                 state,
   Watchdog_Interval              timeout,
+  Watchdog_Clock                 clock,
   uint32_t                       expected_level
 )
 {
@@ -397,6 +401,7 @@ RTEMS_INLINE_ROUTINE void _Thread_queue_Enqueue(
     the_thread,
     state,
     timeout,
+    clock,
     &queue_context
   );
 }
diff --git a/cpukit/score/include/rtems/score/watchdog.h
b/cpukit/score/include/rtems/score/watchdog.h
index c582dbd..b0e71ea 100644
--- a/cpukit/score/include/rtems/score/watchdog.h
+++ b/cpukit/score/include/rtems/score/watchdog.h
@@ -53,6 +53,29 @@ typedef struct Watchdog_Control Watchdog_Control;
 typedef uint32_t   Watchdog_Interval;

 /**
+ *  @brief The kind of clock to use for the Watchdog.
+ *
+ *  This type definition must be consistent with Per_CPU_Watchdog_index type.
+ */
+typedef enum {
+  /**
+   * @brief Relative clock.
+   *
+   * The reference time point for the watchdog is current ticks value
+   * during insert.  Time is measured in clock ticks.
+   */
+  WATCHDOG_RELATIVE,
+
+  /**
+   * @brief Absolute clock.
+   *
+   * The reference time point for this header is the POSIX Epoch.  Time is
+   * measured in nanoseconds since POSIX Epoch.
+   */
+  WATCHDOG_ABSOLUTE
+} Watchdog_Clock;
+
+/**
  *  @brief Return type from a Watchdog Service Routine.
  *
  *  This type defines the return type from a Watchdog Service Routine.
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h
b/cpukit/score/include/rtems/score/watchdogimpl.h
index 2b24cc6..a9b0430 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -342,7 +342,7 @@ RTEMS_INLINE_ROUTINE void
_Watchdog_Per_CPU_release_critical(
 RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_insert_relative(
   Watchdog_Control *the_watchdog,
   Per_CPU_Control  *cpu,
-  uint32_t          ticks
+  uint64_t          ticks
 )
 {
   ISR_lock_Context lock_context;
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index e7d9805..80f1ad7 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -101,6 +101,7 @@ static Per_CPU_Control *_Condition_Do_wait(
     executing,
     STATES_WAITING_FOR_SYS_LOCK_CONDITION,
     timeout,
+    WATCHDOG_RELATIVE,
     queue_context
   );

diff --git a/cpukit/score/src/corebarrierwait.c
b/cpukit/score/src/corebarrierwait.c
index d939acf..3874221 100644
--- a/cpukit/score/src/corebarrierwait.c
+++ b/cpukit/score/src/corebarrierwait.c
@@ -52,6 +52,7 @@ Status_Control _CORE_barrier_Seize(
       executing,
       STATES_WAITING_FOR_BARRIER,
       timeout,
+      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremsgseize.c b/cpukit/score/src/coremsgseize.c
index 6906328..7e6b4ee 100644
--- a/cpukit/score/src/coremsgseize.c
+++ b/cpukit/score/src/coremsgseize.c
@@ -121,6 +121,7 @@ Status_Control _CORE_message_queue_Seize(
     executing,
     STATES_WAITING_FOR_MESSAGE,
     timeout,
+    WATCHDOG_RELATIVE,
     queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremsgsubmit.c b/cpukit/score/src/coremsgsubmit.c
index fb56ffe..d355755 100644
--- a/cpukit/score/src/coremsgsubmit.c
+++ b/cpukit/score/src/coremsgsubmit.c
@@ -139,6 +139,7 @@ Status_Control _CORE_message_queue_Submit(
       executing,
       STATES_WAITING_FOR_MESSAGE,
       timeout,
+      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/coremutexseize.c
b/cpukit/score/src/coremutexseize.c
index ab743c4..5d1f72f 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -21,6 +21,7 @@
 #include <rtems/score/coremuteximpl.h>
 #include <rtems/score/statesimpl.h>
 #include <rtems/score/thread.h>
+#include <rtems/score/watchdog.h>

 Status_Control _CORE_mutex_Seize_slow(
   CORE_mutex_Control   *the_mutex,
@@ -70,6 +71,7 @@ Status_Control _CORE_mutex_Seize_slow(
     executing,
     STATES_WAITING_FOR_MUTEX,
     timeout,
+    WATCHDOG_RELATIVE,
     queue_context
   );

@@ -97,6 +99,7 @@ Status_Control _CORE_mutex_Seize_no_protocol_slow(
       executing,
       STATES_WAITING_FOR_MUTEX,
       timeout,
+      WATCHDOG_RELATIVE,
       queue_context
     );
     return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/corerwlockobtainread.c
b/cpukit/score/src/corerwlockobtainread.c
index bce992c..43089d0 100644
--- a/cpukit/score/src/corerwlockobtainread.c
+++ b/cpukit/score/src/corerwlockobtainread.c
@@ -86,6 +86,7 @@ Status_Control _CORE_RWLock_Seize_for_reading(
      executing,
      STATES_WAITING_FOR_RWLOCK,
      timeout,
+     WATCHDOG_RELATIVE,
      queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/corerwlockobtainwrite.c
b/cpukit/score/src/corerwlockobtainwrite.c
index c261d32..7d9815a 100644
--- a/cpukit/score/src/corerwlockobtainwrite.c
+++ b/cpukit/score/src/corerwlockobtainwrite.c
@@ -74,6 +74,7 @@ Status_Control _CORE_RWLock_Seize_for_writing(
      executing,
      STATES_WAITING_FOR_RWLOCK,
      timeout,
+     WATCHDOG_RELATIVE,
      queue_context
   );
   return _Thread_Wait_get_status( executing );
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index a192509..f585f99 100644
--- a/cpukit/score/src/futex.c
+++ b/cpukit/score/src/futex.c
@@ -95,6 +95,7 @@ int _Futex_Wait( struct _Futex_Control *_futex, int
*uaddr, int val )
       executing,
       STATES_WAITING_FOR_SYS_LOCK_FUTEX,
       WATCHDOG_NO_TIMEOUT,
+      WATCHDOG_RELATIVE,
       &queue_context
     );
     eno = 0;
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 9eb169b..30afdb1 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -261,6 +261,7 @@ Status_Control _MPCI_Send_request_packet(
       executing,
       STATES_WAITING_FOR_RPC_REPLY | extra_state,
       the_packet->timeout,
+      WATCHDOG_RELATIVE,
       2
     );

diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index ed374a0..e7b631e 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -116,6 +116,7 @@ static void _Mutex_Acquire_slow(
     executing,
     STATES_WAITING_FOR_SYS_LOCK_MUTEX,
     timeout,
+    WATCHDOG_RELATIVE,
     queue_context
   );
 }
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index 03af9cf..84907e2 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -107,6 +107,7 @@ void _Semaphore_Wait( struct _Semaphore_Control *_sem )
       executing,
       STATES_WAITING_FOR_SYS_LOCK_SEMAPHORE,
       WATCHDOG_NO_TIMEOUT,
+      WATCHDOG_RELATIVE,
       &queue_context
     );
   }
diff --git a/cpukit/score/src/threadqenqueue.c
b/cpukit/score/src/threadqenqueue.c
index 1e95003..6a14fec 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -40,6 +40,7 @@ void _Thread_queue_Enqueue_critical(
   Thread_Control                *the_thread,
   States_Control                 state,
   Watchdog_Interval              timeout,
+  Watchdog_Clock                 clock,
   Thread_queue_Context          *queue_context
 )
 {
@@ -84,11 +85,12 @@ void _Thread_queue_Enqueue_critical(
    *  If the thread wants to timeout, then schedule its timer.
    */
   if ( timeout != WATCHDOG_NO_TIMEOUT ) {
-    _Thread_Timer_insert_relative(
+    _Thread_Timer_insert(
       the_thread,
       cpu_self,
       _Thread_Timeout,
-      timeout
+      timeout,
+      clock
     );
   }

diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index f155980..1bb18aa 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -462,6 +462,7 @@ void _Thread_Join(
     executing,
     waiting_for_join,
     WATCHDOG_NO_TIMEOUT,
+    WATCHDOG_RELATIVE,
     queue_context
   );
 }
--
1.9.1


More information about the devel mailing list