[PATCH 03/12] score: Add and use _Thread_Dispatch_if_necessary()
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Jun 12 15:12:29 UTC 2013
Delete _Thread_Evaluate_is_dispatch_needed().
Use _Thread_Dispatch_is_enabled() in rtems_task_mode() instead of the
system state to determine if a thread dispatch is allowed. Signales are
now delivered in rtems_task_mode() even if preemption is disabled. This
is in line with rtems_signal_send().
---
cpukit/rtems/src/taskmode.c | 5 +--
cpukit/score/inline/rtems/score/thread.inl | 52 ++++++++++++++--------------
2 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/cpukit/rtems/src/taskmode.c b/cpukit/rtems/src/taskmode.c
index 66cf505..7b3233e 100644
--- a/cpukit/rtems/src/taskmode.c
+++ b/cpukit/rtems/src/taskmode.c
@@ -100,10 +100,7 @@ rtems_status_code rtems_task_mode(
}
}
- if ( _System_state_Is_up( _System_state_Get() ) ) {
- if (_Thread_Evaluate_is_dispatch_needed( needs_asr_dispatching ) )
- _Thread_Dispatch();
- }
+ _Thread_Dispatch_if_necessary( executing, needs_asr_dispatching );
return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl
index e6e1929..4576dea 100644
--- a/cpukit/score/inline/rtems/score/thread.inl
+++ b/cpukit/score/inline/rtems/score/thread.inl
@@ -223,6 +223,32 @@ RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_global_exit_status( void )
}
/**
+ * @brief Issues a thread dispatch if necessary.
+ *
+ * @param[in] executing The executing thread.
+ * @param[in] needs_asr_dispatching Indicates whether or not the API
+ * level signals are pending and a dispatch is necessary.
+ */
+RTEMS_INLINE_ROUTINE void _Thread_Dispatch_if_necessary(
+ Thread_Control *executing,
+ bool needs_asr_dispatching
+)
+{
+ if ( _Thread_Dispatch_is_enabled() ) {
+ bool dispatch_necessary = needs_asr_dispatching;
+
+ if ( !_Thread_Is_heir( executing ) && executing->is_preemptible ) {
+ dispatch_necessary = true;
+ _Thread_Dispatch_necessary = dispatch_necessary;
+ }
+
+ if ( dispatch_necessary ) {
+ _Thread_Dispatch();
+ }
+ }
+}
+
+/**
* This routine returns the C library re-enterant pointer.
*/
@@ -242,32 +268,6 @@ RTEMS_INLINE_ROUTINE void _Thread_Set_libc_reent (
_Thread_libc_reent = libc_reent;
}
-/**
- * This routine evaluates the current scheduling information for the
- * system and determines if a context switch is required. This
- * is usually called after changing an execution mode such as preemptability
- * for a thread.
- *
- * @param[in] are_signals_pending specifies whether or not the API
- * level signals are pending and a dispatch is needed.
- */
-RTEMS_INLINE_ROUTINE bool _Thread_Evaluate_is_dispatch_needed(
- bool are_signals_pending
-)
-{
- Thread_Control *executing;
-
- executing = _Thread_Executing;
-
- if ( are_signals_pending ||
- (!_Thread_Is_heir( executing ) && executing->is_preemptible) ) {
- _Thread_Dispatch_necessary = true;
- return true;
- }
-
- return false;
-}
-
/** @}*/
#endif
--
1.7.7
More information about the devel
mailing list