[PATCH 3/5] score: Add _Thread_Get_maximum_internal_threads()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jan 29 10:17:50 UTC 2014


---
 cpukit/score/include/rtems/score/threadimpl.h |   19 +++++++++++++++++++
 cpukit/score/src/thread.c                     |   12 +-----------
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index e07b392..6eb7a03 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -23,7 +23,9 @@
 #include <rtems/score/isr.h>
 #include <rtems/score/objectimpl.h>
 #include <rtems/score/statesimpl.h>
+#include <rtems/score/sysstate.h>
 #include <rtems/score/todimpl.h>
+#include <rtems/config.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -592,6 +594,23 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_proxy_blocking (
   return (code == THREAD_STATUS_PROXY_BLOCKING);
 }
 
+RTEMS_INLINE_ROUTINE uint32_t _Thread_Get_maximum_internal_threads(void)
+{
+  uint32_t maximum_internal_threads = 0;
+
+  /* Idle threads */
+  maximum_internal_threads += rtems_configuration_get_maximum_processors();
+
+  /* MPCI thread */
+#if defined(RTEMS_MULTIPROCESSING)
+  if ( _System_state_Is_multiprocessing ) {
+    ++maximum_internal_threads;
+  }
+#endif
+
+  return maximum_internal_threads;
+}
+
 /**
  * This routine allocates an internal thread.
  */
diff --git a/cpukit/score/src/thread.c b/cpukit/score/src/thread.c
index 9d2301b..5587ac3 100644
--- a/cpukit/score/src/thread.c
+++ b/cpukit/score/src/thread.c
@@ -20,8 +20,6 @@
 
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/interr.h>
-#include <rtems/score/sysstate.h>
-#include <rtems/config.h>
 
 void _Thread_Handler_initialization(void)
 {
@@ -31,7 +29,6 @@ void _Thread_Handler_initialization(void)
     rtems_configuration_get_maximum_extensions();
   rtems_stack_allocate_init_hook stack_allocate_init_hook =
     rtems_configuration_get_stack_allocate_init_hook();
-  uint32_t     maximum_internal_threads;
   #if defined(RTEMS_MULTIPROCESSING)
     uint32_t maximum_proxies =
       _Configuration_MP_table->maximum_proxies;
@@ -68,18 +65,11 @@ void _Thread_Handler_initialization(void)
    *  per CPU in an SMP system.  In addition, if this is a loosely
    *  coupled multiprocessing system, account for the MPCI Server Thread.
    */
-  maximum_internal_threads = rtems_configuration_get_maximum_processors();
-
-  #if defined(RTEMS_MULTIPROCESSING)
-    if ( _System_state_Is_multiprocessing )
-      maximum_internal_threads += 1;
-  #endif
-
   _Objects_Initialize_information(
     &_Thread_Internal_information,
     OBJECTS_INTERNAL_API,
     OBJECTS_INTERNAL_THREADS,
-    maximum_internal_threads,
+    _Thread_Get_maximum_internal_threads(),
     sizeof( Thread_Control ),
                                 /* size of this object's control block */
     false,                      /* true if names for this object are strings */
-- 
1.7.7




More information about the devel mailing list