[rtems commit] config: Statically allocate MP thread proxies

Sebastian Huber sebh at rtems.org
Fri Dec 13 09:10:24 UTC 2019


Module:    rtems
Branch:    master
Commit:    1d9f509e68a431d902cc655c85dc0601be4617b0
Changeset: http://git.rtems.org/rtems/commit/?id=1d9f509e68a431d902cc655c85dc0601be4617b0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Dec 12 08:43:06 2019 +0100

config: Statically allocate MP thread proxies

Update #3735.

---

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

diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index 692470c..23fa5b4 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -1831,10 +1831,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>
@@ -1850,6 +1846,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 */
@@ -2391,8 +2399,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 fd99e8b..bd8de4e 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 60f1ef3..beb3221 100644
--- a/cpukit/score/src/mpcidefault.c
+++ b/cpukit/score/src/mpcidefault.c
@@ -20,6 +20,9 @@
 
 #include <rtems/score/mpci.h>
 #include <rtems/score/stack.h>
+#include <rtems/score/thread.h>
+
+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 e0c9da1..e60aeed 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,



More information about the vc mailing list