summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/score/include')
-rw-r--r--cpukit/score/include/rtems/score/interr.h3
-rw-r--r--cpukit/score/include/rtems/score/threaddispatch.h19
2 files changed, 20 insertions, 2 deletions
diff --git a/cpukit/score/include/rtems/score/interr.h b/cpukit/score/include/rtems/score/interr.h
index e23db5c58d..4e499d8198 100644
--- a/cpukit/score/include/rtems/score/interr.h
+++ b/cpukit/score/include/rtems/score/interr.h
@@ -166,7 +166,8 @@ typedef enum {
INTERNAL_ERROR_POSIX_INIT_THREAD_ENTRY_IS_NULL,
INTERNAL_ERROR_THREAD_QUEUE_DEADLOCK,
INTERNAL_ERROR_THREAD_QUEUE_ENQUEUE_STICKY_FROM_BAD_STATE,
- INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL
+ INTERNAL_ERROR_BAD_THREAD_DISPATCH_DISABLE_LEVEL,
+ INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT
} Internal_errors_Core_list;
typedef CPU_Uint32ptr Internal_errors_t;
diff --git a/cpukit/score/include/rtems/score/threaddispatch.h b/cpukit/score/include/rtems/score/threaddispatch.h
index f4ca096783..0238f8f5d5 100644
--- a/cpukit/score/include/rtems/score/threaddispatch.h
+++ b/cpukit/score/include/rtems/score/threaddispatch.h
@@ -28,6 +28,18 @@ extern "C" {
* @{
*/
+#if defined(RTEMS_SMP) || ( CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE )
+/**
+ * @brief Enables a robust thread dispatch.
+ *
+ * On each change of the thread dispatch disable level from one to zero the
+ * interrupt status is checked. In case interrupts are disabled and SMP is
+ * enabled or the CPU port needs it, then the system terminates with the fatal
+ * internal error INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT.
+ */
+#define RTEMS_SCORE_ROBUST_THREAD_DISPATCH
+#endif
+
/**
* @brief Indicates if the executing thread is inside a thread dispatch
* critical section.
@@ -206,7 +218,12 @@ RTEMS_INLINE_ROUTINE void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self )
_ISR_Local_disable( level );
- if ( cpu_self->dispatch_necessary ) {
+ if (
+ cpu_self->dispatch_necessary
+#if defined(RTEMS_SCORE_ROBUST_THREAD_DISPATCH)
+ || !_ISR_Is_enabled( level )
+#endif
+ ) {
_Thread_Do_dispatch( cpu_self, level );
} else {
cpu_self->thread_dispatch_disable_level = 0;