[PATCH 3/5] config: Statically allocate MP thread proxies

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Dec 12 08:43:05 UTC 2019


Update #3735.
---
 cpukit/include/rtems/confdefs.h     | 19 +++++++++++++------
 cpukit/include/rtems/score/thread.h | 17 +++++++++++++++++
 cpukit/score/src/mpcidefault.c      |  7 +++++++
 cpukit/score/src/threadmp.c         |  6 +-----
 4 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index c827f2c188..20ffd6e7ba 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -1842,10 +1842,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
     #ifndef CONFIGURE_MP_MAXIMUM_PROXIES
       #define CONFIGURE_MP_MAXIMUM_PROXIES            32
     #endif
-    #define _CONFIGURE_MEMORY_FOR_PROXIES(_proxies) \
-      _Configure_From_workspace((_proxies) \
-        * (sizeof(Thread_Proxy_control) \
-          + sizeof(Thread_queue_Configured_heads)))
 
     #ifndef CONFIGURE_MP_MPCI_TABLE_POINTER
       #include <mpci.h>
@@ -1861,6 +1857,18 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
         #error "CONFIGURE_MP_NODE_NUMBER must be less than or equal to CONFIGURE_MP_MAXIMUM_NODES"
       #endif
 
+      struct Thread_Configured_proxy_control {
+        Thread_Proxy_control Control;
+        Thread_queue_Configured_heads Heads;
+      };
+
+      static Thread_Configured_proxy_control _Thread_MP_Configured_proxies[
+        CONFIGURE_MP_MAXIMUM_PROXIES
+      ];
+
+      Thread_Configured_proxy_control * const _Thread_MP_Proxies =
+        &_Thread_MP_Configured_proxies[ 0 ];
+
       const MPCI_Configuration _MPCI_Configuration = {
         CONFIGURE_MP_NODE_NUMBER,               /* local node number */
         CONFIGURE_MP_MAXIMUM_NODES,             /* maximum # nodes */
@@ -2409,8 +2417,7 @@ struct _reent *__getreent(void)
  */
 #ifdef CONFIGURE_MP_APPLICATION
   #define _CONFIGURE_MEMORY_FOR_MP \
-    (_CONFIGURE_MEMORY_FOR_PROXIES(CONFIGURE_MP_MAXIMUM_PROXIES) + \
-     _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS))
+     _CONFIGURE_MEMORY_FOR_GLOBAL_OBJECTS(CONFIGURE_MP_MAXIMUM_GLOBAL_OBJECTS)
 #else
   #define _CONFIGURE_MEMORY_FOR_MP  0
 #endif
diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h
index fd99e8bb77..bd8de4ef81 100644
--- a/cpukit/include/rtems/score/thread.h
+++ b/cpukit/include/rtems/score/thread.h
@@ -1065,6 +1065,23 @@ Thread_Information name##_Information = { \
   } \
 }
 
+#if defined(RTEMS_MULTIPROCESSING)
+/**
+ * @brief The configured thread control block.
+ *
+ * This type is defined in <rtems/confdefs.h> and depends on the application
+ * configuration.
+ */
+typedef struct Thread_Configured_proxy_control Thread_Configured_proxy_control;
+
+/**
+ * @brief The configured proxies.
+ *
+ * Provided by the application via <rtems/confdefs.h>.
+ */
+extern Thread_Configured_proxy_control * const _Thread_MP_Proxies;
+#endif
+
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/score/src/mpcidefault.c b/cpukit/score/src/mpcidefault.c
index 60f1ef31a7..9957f782fd 100644
--- a/cpukit/score/src/mpcidefault.c
+++ b/cpukit/score/src/mpcidefault.c
@@ -20,6 +20,13 @@
 
 #include <rtems/score/mpci.h>
 #include <rtems/score/stack.h>
+#include <rtems/score/thread.h>
+
+struct Thread_Configured_proxy_control {
+  int dummy;
+};
+
+Thread_Configured_proxy_control * const _Thread_MP_Proxies;
 
 const MPCI_Configuration _MPCI_Configuration = {
   1,                        /* local node number */
diff --git a/cpukit/score/src/threadmp.c b/cpukit/score/src/threadmp.c
index e0c9da15e7..e60aeed893 100644
--- a/cpukit/score/src/threadmp.c
+++ b/cpukit/score/src/threadmp.c
@@ -21,7 +21,6 @@
 #include <rtems/score/threadimpl.h>
 #include <rtems/score/isrlock.h>
 #include <rtems/score/schedulerimpl.h>
-#include <rtems/score/wkspace.h>
 
 #include <string.h>
 
@@ -46,7 +45,6 @@ void _Thread_MP_Handler_initialization (
 )
 {
   size_t    proxy_size;
-  size_t    alloc_size;
   char     *proxies;
   uint32_t  i;
 
@@ -55,9 +53,7 @@ void _Thread_MP_Handler_initialization (
   }
 
   proxy_size = sizeof( Thread_Proxy_control ) + _Thread_queue_Heads_size;
-  alloc_size = maximum_proxies * proxy_size;
-  proxies = _Workspace_Allocate_or_fatal_error( alloc_size );
-  memset( proxies, 0, alloc_size );
+  proxies = (char *) _Thread_MP_Proxies;
 
   _Chain_Initialize(
     &_Thread_MP_Inactive_proxies,
-- 
2.16.4



More information about the devel mailing list