summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/thread.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-11-22 19:14:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-12-14 07:03:29 +0100
commit21275b58a5a69c3c838082ffc8a7a3641f32ea9a (patch)
treed331e17c15d71f107d0f14581a93ddf768b05813 /cpukit/include/rtems/score/thread.h
parentrtems: Use object information to get config max (diff)
downloadrtems-21275b58a5a69c3c838082ffc8a7a3641f32ea9a.tar.bz2
score: Static Objects_Information initialization
Statically allocate the objects information together with the initial set of objects either via <rtems/confdefs.h>. Provide default object informations with zero objects via librtemscpu.a. This greatly simplifies the workspace size estimate. RTEMS applications which do not use the unlimited objects option are easier to debug since all objects reside now in statically allocated objects of the right types. Close #3621.
Diffstat (limited to 'cpukit/include/rtems/score/thread.h')
-rw-r--r--cpukit/include/rtems/score/thread.h118
1 files changed, 113 insertions, 5 deletions
diff --git a/cpukit/include/rtems/score/thread.h b/cpukit/include/rtems/score/thread.h
index 7e24af43c9..9bf920d5fb 100644
--- a/cpukit/include/rtems/score/thread.h
+++ b/cpukit/include/rtems/score/thread.h
@@ -26,6 +26,7 @@
#if defined(RTEMS_MULTIPROCESSING)
#include <rtems/score/mppkt.h>
#endif
+#include <rtems/score/freechain.h>
#include <rtems/score/isrlock.h>
#include <rtems/score/objectdata.h>
#include <rtems/score/priority.h>
@@ -909,7 +910,7 @@ typedef struct {
*
* This array is provided via <rtems/confdefs.h>.
*
- * @see _Thread_Control_add_on_count and _Thread_Control_size.
+ * @see _Thread_Control_add_on_count.
*/
extern const Thread_Control_add_on _Thread_Control_add_ons[];
@@ -923,13 +924,11 @@ extern const Thread_Control_add_on _Thread_Control_add_ons[];
extern const size_t _Thread_Control_add_on_count;
/**
- * @brief Size of the thread control block of a particular application.
+ * @brief Count of configured threads.
*
* This value is provided via <rtems/confdefs.h>.
- *
- * @see _Thread_Control_add_ons.
*/
-extern const size_t _Thread_Control_size;
+extern const size_t _Thread_Initial_thread_count;
/**
* @brief Maximum size of a thread name in characters (including the
@@ -939,6 +938,115 @@ extern const size_t _Thread_Control_size;
*/
extern const size_t _Thread_Maximum_name_size;
+/**
+ * @brief The configured thread control block.
+ *
+ * This type is defined in <rtems/confdefs.h> and depends on the application
+ * configuration.
+ */
+typedef struct Thread_Configured_control Thread_Configured_control;
+
+/**
+ * @brief The configured thread queue heads.
+ *
+ * In SMP configurations, this type is defined in <rtems/confdefs.h> and depends
+ * on the application configuration.
+ */
+#if defined(RTEMS_SMP)
+typedef struct Thread_queue_Configured_heads Thread_queue_Configured_heads;
+#else
+typedef Thread_queue_Heads Thread_queue_Configured_heads;
+#endif
+
+/**
+ * @brief Size of the thread queue heads of a particular application.
+ *
+ * In SMP configurations, this value is provided via <rtems/confdefs.h>.
+ */
+#if defined(RTEMS_SMP)
+extern const size_t _Thread_queue_Heads_size;
+#else
+#define _Thread_queue_Heads_size sizeof(Thread_queue_Heads)
+#endif
+
+/**
+ * @brief The thread object information.
+ */
+typedef struct {
+ /**
+ * @brief The object information.
+ */
+ Objects_Information Objects;
+
+ /**
+ * @brief Thread queue heads maintenance.
+ */
+ union {
+ /**
+ * @brief Contains the initial set of thread queue heads.
+ *
+ * This is set by <rtems/confdefs.h> via THREAD_INFORMATION_DEFINE().
+ */
+ Thread_queue_Configured_heads *initial;
+
+ /**
+ * @brief The free thread queue heads.
+ *
+ * This member is initialized by _Thread_Initialize_information().
+ */
+ Freechain_Control Free;
+ } Thread_queue_heads;
+} Thread_Information;
+
+/**
+ * @brief The internal thread objects information.
+ */
+extern Thread_Information _Thread_Information;
+
+#define THREAD_INFORMATION_DEFINE_ZERO( name, api, cls ) \
+Thread_Information name##_Information = { \
+ { \
+ _Objects_Build_id( api, cls, 1, 0 ), \
+ NULL, \
+ 0, \
+ 0, \
+ 0, \
+ 0, \
+ CHAIN_INITIALIZER_EMPTY( name##_Information.Objects.Inactive ), \
+ NULL, \
+ NULL, \
+ NULL \
+ OBJECTS_INFORMATION_MP( name##_Information.Objects, NULL ), \
+ }, { \
+ NULL \
+ } \
+}
+
+#define THREAD_INFORMATION_DEFINE( name, api, cls, max ) \
+static Objects_Control * \
+name##_Local_table[ _Objects_Maximum_per_allocation( max ) ]; \
+static Thread_Configured_control \
+name##_Objects[ _Objects_Maximum_per_allocation( max ) ]; \
+static Thread_queue_Configured_heads \
+name##_Heads[ _Objects_Maximum_per_allocation( max ) ]; \
+Thread_Information name##_Information = { \
+ { \
+ _Objects_Build_id( api, cls, 1, _Objects_Maximum_per_allocation( max ) ), \
+ name##_Local_table, \
+ 0, \
+ _Objects_Is_unlimited( max ) ? _Objects_Maximum_per_allocation( max ) : 0, \
+ sizeof( Thread_Configured_control ), \
+ OBJECTS_NO_STRING_NAME, \
+ CHAIN_INITIALIZER_EMPTY( name##_Information.Objects.Inactive ), \
+ NULL, \
+ NULL, \
+ &name##_Objects[ 0 ].Control.Object \
+ OBJECTS_INFORMATION_MP( name##_Information.Objects, NULL ) \
+ }, { \
+ &name##_Heads[ 0 ] \
+ } \
+}
+
/**@}*/
#ifdef __cplusplus