[rtems commit] sptests/spintrcritical09: Fix check order

Sebastian Huber sebh at rtems.org
Tue Nov 13 08:35:36 UTC 2012


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Nov 12 17:58:48 2012 +0100

sptests/spintrcritical09: Fix check order

The critical section check never succeeded since watchdogs are ordered
with respect to the insertion time.  Now we call the watchdog routine if
appropriate and bypass the normal watchdog mechanic.

---

 testsuites/sptests/spintrcritical09/init.c |   42 ++++++++++++++++-----------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/testsuites/sptests/spintrcritical09/init.c b/testsuites/sptests/spintrcritical09/init.c
index c953799..a00aae0 100644
--- a/testsuites/sptests/spintrcritical09/init.c
+++ b/testsuites/sptests/spintrcritical09/init.c
@@ -15,16 +15,10 @@
 #include <tmacros.h>
 #include <intrcritical.h>
 
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
-Thread_blocking_operation_States getState(void);
+static rtems_id Semaphore;
+static bool case_hit;
 
-rtems_id Main_task;
-rtems_id Semaphore;
-volatile bool case_hit;
-
-Thread_blocking_operation_States getState(void)
+static Thread_blocking_operation_States getState(void)
 {
   Objects_Locations  location;
   Semaphore_Control *sem;
@@ -40,17 +34,33 @@ Thread_blocking_operation_States getState(void)
   return sem->Core_control.semaphore.Wait_queue.sync_state;
 }
 
-rtems_timer_service_routine test_release_from_isr(
+static rtems_timer_service_routine test_release_from_isr(
   rtems_id  timer,
   void     *arg
 )
 {
-  if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) {
-    case_hit = true;
+  Chain_Control *chain = &_Watchdog_Ticks_chain;
+
+  if ( !_Chain_Is_empty( chain ) ) {
+    Watchdog_Control *watchdog = _Watchdog_First( chain );
+
+    if (
+      watchdog->delta_interval == 0
+        && watchdog->routine == _Thread_queue_Timeout
+    ) {
+      Watchdog_States state = _Watchdog_Remove( watchdog );
+
+      rtems_test_assert( state == WATCHDOG_ACTIVE );
+      (*watchdog->routine)( watchdog->id, watchdog->user_data );
+
+      if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) {
+        case_hit = true;
+      }
+    }
   }
 }
 
-rtems_task Init(
+static rtems_task Init(
   rtems_task_argument ignored
 )
 {
@@ -63,15 +73,13 @@ rtems_task Init(
   puts( "Init - Trying to generate timeout from ISR while blocking" );
   sc = rtems_semaphore_create(
     rtems_build_name( 'S', 'M', '1', ' ' ),
-    1,
+    0,
     RTEMS_DEFAULT_ATTRIBUTES,
     RTEMS_NO_PRIORITY,
     &Semaphore
   );
   directive_failed( sc, "rtems_semaphore_create of SM1" );
 
-  Main_task = rtems_task_self();
-
   interrupt_critical_section_test_support_initialize( test_release_from_isr );
 
   case_hit = false;
@@ -97,7 +105,7 @@ rtems_task Init(
 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 
-#define CONFIGURE_MAXIMUM_TASKS       2
+#define CONFIGURE_MAXIMUM_TASKS       1
 #define CONFIGURE_MAXIMUM_TIMERS      1
 #define CONFIGURE_MAXIMUM_SEMAPHORES  1
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE




More information about the vc mailing list