[PATCH 1/3] score: Delete _Assert_Thread_dispatching_repressed

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Mar 18 12:13:06 UTC 2014


Add _Debug_Is_thread_dispatching_allowed().  This makes it possible to
assert the opposite.

Use _ISR_Disable_without_giant()/_ISR_Enable_without_giant() to avoid
misleading secondary assertion failures.
---
 cpukit/score/Makefile.am                           |    2 +-
 cpukit/score/include/rtems/score/assert.h          |    8 ++---
 .../score/src/assertthreaddispatchingrepressed.c   |   37 --------------------
 cpukit/score/src/debugisthreaddispatchingallowed.c |   37 ++++++++++++++++++++
 cpukit/score/src/smp.c                             |    2 +-
 5 files changed, 42 insertions(+), 44 deletions(-)
 delete mode 100644 cpukit/score/src/assertthreaddispatchingrepressed.c
 create mode 100644 cpukit/score/src/debugisthreaddispatchingallowed.c

diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 29b742b..13f2cd6 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -331,7 +331,7 @@ libscore_a_SOURCES += src/apiext.c src/chain.c src/chainappend.c \
     src/chainextract.c src/chainget.c src/chaininsert.c \
     src/chainappendempty.c src/chainprependempty.c src/chaingetempty.c \
     src/chainnodecount.c \
-    src/assertthreaddispatchingrepressed.c \
+    src/debugisthreaddispatchingallowed.c \
     src/interr.c src/isr.c src/wkspace.c src/wkstringduplicate.c
 libscore_a_SOURCES += src/profilingisrentryexit.c
 
diff --git a/cpukit/score/include/rtems/score/assert.h b/cpukit/score/include/rtems/score/assert.h
index 4856eae..0248b3c 100644
--- a/cpukit/score/include/rtems/score/assert.h
+++ b/cpukit/score/include/rtems/score/assert.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -39,15 +39,13 @@ extern "C" {
 #endif
 
 /**
- * @brief Asserts that thread dispatching is repressed.
+ * @brief Returns true if thread dispatching is allowed.
  *
  * Thread dispatching can be repressed via _Thread_Disable_dispatch() or
  * _ISR_Disable().
  */
 #if defined( RTEMS_DEBUG )
-  void _Assert_Thread_dispatching_repressed( void );
-#else
-  #define _Assert_Thread_dispatching_repressed() ( ( void ) 0 )
+  bool _Debug_Is_thread_dispatching_allowed( void );
 #endif
 
 /**
diff --git a/cpukit/score/src/assertthreaddispatchingrepressed.c b/cpukit/score/src/assertthreaddispatchingrepressed.c
deleted file mode 100644
index 0d586f8..0000000
--- a/cpukit/score/src/assertthreaddispatchingrepressed.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
- *
- *  embedded brains GmbH
- *  Dornierstr. 4
- *  82178 Puchheim
- *  Germany
- *  <rtems at embedded-brains.de>
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/score/assert.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/threaddispatch.h>
-
-#if defined( RTEMS_DEBUG )
-  void _Assert_Thread_dispatching_repressed( void )
-  {
-    bool dispatch_is_disabled;
-    ISR_Level level;
-    Per_CPU_Control *per_cpu;
-
-    _ISR_Disable( level );
-    per_cpu = _Per_CPU_Get_by_index( _SMP_Get_current_processor() );
-    dispatch_is_disabled = per_cpu->thread_dispatch_disable_level != 0;
-    _ISR_Enable( level );
-
-    _Assert( dispatch_is_disabled || _ISR_Get_level() != 0 );
-  }
-#endif
diff --git a/cpukit/score/src/debugisthreaddispatchingallowed.c b/cpukit/score/src/debugisthreaddispatchingallowed.c
new file mode 100644
index 0000000..fa5b502
--- /dev/null
+++ b/cpukit/score/src/debugisthreaddispatchingallowed.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  <rtems at embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+  #include "config.h"
+#endif
+
+#include <rtems/score/assert.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/threaddispatch.h>
+
+#if defined( RTEMS_DEBUG )
+  bool _Debug_Is_thread_dispatching_allowed( void )
+  {
+    bool dispatch_allowed;
+    ISR_Level level;
+    Per_CPU_Control *per_cpu;
+
+    _ISR_Disable_without_giant( level );
+    per_cpu = _Per_CPU_Get_by_index( _SMP_Get_current_processor() );
+    dispatch_allowed = per_cpu->thread_dispatch_disable_level == 0;
+    _ISR_Enable_without_giant( level );
+
+    return dispatch_allowed && _ISR_Get_level() == 0;
+  }
+#endif
diff --git a/cpukit/score/src/smp.c b/cpukit/score/src/smp.c
index 389a4d6..8e57ed0 100644
--- a/cpukit/score/src/smp.c
+++ b/cpukit/score/src/smp.c
@@ -100,7 +100,7 @@ void _SMP_Broadcast_message( uint32_t message )
   uint32_t ncpus = _SMP_Get_processor_count();
   uint32_t cpu;
 
-  _Assert_Thread_dispatching_repressed();
+  _Assert( _Debug_Is_thread_dispatching_allowed() );
 
   for ( cpu = 0 ; cpu < ncpus ; ++cpu ) {
     if ( cpu != self ) {
-- 
1.7.7




More information about the devel mailing list