[rtems commit] score: Simplify debug code and use _Assert()

Sebastian Huber sebh at rtems.org
Sun Mar 22 15:03:20 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sun Mar 22 14:31:59 2015 +0100

score: Simplify debug code and use _Assert()

---

 cpukit/sapi/src/interrtext.c                       |  2 +-
 cpukit/score/include/rtems/score/interr.h          |  2 +-
 cpukit/score/src/threadqenqueue.c                  | 67 ++++------------------
 .../spinternalerror02/spinternalerror02.scn        |  2 +-
 4 files changed, 13 insertions(+), 60 deletions(-)

diff --git a/cpukit/sapi/src/interrtext.c b/cpukit/sapi/src/interrtext.c
index e08414b..09bc215 100644
--- a/cpukit/sapi/src/interrtext.c
+++ b/cpukit/sapi/src/interrtext.c
@@ -44,7 +44,7 @@ static const char *const internal_error_text[] = {
   "INTERNAL_ERROR_BAD_STACK_HOOK",
   "INTERNAL_ERROR_BAD_ATTRIBUTES",
   "INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY",
-  "INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
+  "OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL",
   "INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE",
   "INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0",
   "OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP",
diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h
index dcf2f2f..988a00d 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -153,7 +153,7 @@ typedef enum {
   INTERNAL_ERROR_BAD_STACK_HOOK,
   INTERNAL_ERROR_BAD_ATTRIBUTES,
   INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY,
-  INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL,
+  OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL,
   INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE,
   INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0,
   OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP,
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index e1e876c..39353fe 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -19,6 +19,7 @@
 #endif
 
 #include <rtems/score/threadqimpl.h>
+#include <rtems/score/assert.h>
 #include <rtems/score/isrlevel.h>
 #include <rtems/score/rbtreeimpl.h>
 #include <rtems/score/threadimpl.h>
@@ -72,60 +73,6 @@ static void _Thread_blocking_operation_Finalize(
 #endif
 }
 
-/**
- *  @brief Cancel a blocking operation due to ISR.
- *
- *  This method is used to cancel a blocking operation that was
- *  satisfied from an ISR while the thread executing was in the
- *  process of blocking.
- *
- *  This method will restore the previous ISR disable level during the cancel
- *  operation.  Thus it is an implicit _ISR_Enable().
- *
- *  @param[in] sync_state is the synchronization state
- *  @param[in] the_thread is the thread whose blocking is canceled
- *  @param[in] level is the previous ISR disable level
- *
- *  @note This is a rare routine in RTEMS.  It is called with
- *        interrupts disabled and only when an ISR completed
- *        a blocking condition in process.
- */
-static void _Thread_blocking_operation_Cancel(
-  Thread_blocking_operation_States  sync_state,
-  Thread_Control                   *the_thread,
-  ISR_Level                         level
-)
-{
-  /*
-   *  Cases that should not happen and why.
-   *
-   *  THREAD_BLOCKING_OPERATION_SYNCHRONIZED:
-   *
-   *  This indicates that someone did not enter a blocking
-   *  operation critical section.
-   *
-   *  THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED:
-   *
-   *  This indicates that there was nothing to cancel so
-   *  we should not have been called.
-   */
-
-  #if defined(RTEMS_DEBUG)
-    if ( (sync_state == THREAD_BLOCKING_OPERATION_SYNCHRONIZED) ||
-         (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) ) {
-      _Terminate(
-        INTERNAL_ERROR_CORE,
-        true,
-        INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
-      );
-    }
-  #else
-    (void) sync_state;
-  #endif
-
-  _Thread_blocking_operation_Finalize( the_thread, level );
-}
-
 void _Thread_queue_Enqueue_with_handler(
   Thread_queue_Control         *the_thread_queue,
   Thread_Control               *the_thread,
@@ -191,9 +138,15 @@ void _Thread_queue_Enqueue_with_handler(
     the_thread->Wait.queue = the_thread_queue;
     the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
     _ISR_Enable( level );
-    return;
-  } else { /* sync_state != THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) */
-    _Thread_blocking_operation_Cancel( sync_state, the_thread, level );
+  } else {
+    /* Cancel a blocking operation due to ISR */
+
+    _Assert(
+      sync_state == THREAD_BLOCKING_OPERATION_TIMEOUT ||
+        sync_state == THREAD_BLOCKING_OPERATION_SATISFIED
+    );
+
+    _Thread_blocking_operation_Finalize( the_thread, level );
   }
 }
 
diff --git a/testsuites/sptests/spinternalerror02/spinternalerror02.scn b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
index 89f571e..1159654 100644
--- a/testsuites/sptests/spinternalerror02/spinternalerror02.scn
+++ b/testsuites/sptests/spinternalerror02/spinternalerror02.scn
@@ -16,7 +16,7 @@ INTERNAL_ERROR_INVALID_GLOBAL_ID
 INTERNAL_ERROR_BAD_STACK_HOOK
 INTERNAL_ERROR_BAD_ATTRIBUTES
 INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY
-INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
+OBSOLETE_INTERNAL_ERROR_IMPLEMENTATION_BLOCKING_OPERATION_CANCEL
 INTERNAL_ERROR_MUTEX_OBTAIN_FROM_BAD_STATE
 INTERNAL_ERROR_UNLIMITED_AND_MAXIMUM_IS_0
 OBSOLETE_INTERNAL_ERROR_SHUTDOWN_WHEN_NOT_UP




More information about the vc mailing list