[PATCH 2/2] rtems: Simplify semaphore configuration
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Dec 9 09:11:02 UTC 2019
The MrsP semaphore implementation predates the addition of
self-contained synchronization objects. At this time, the potential
memory reduction was justified considering the more complex
configuration and additional use of the workspace. With the
availability of self-contained synchronization options, e.g. POSIX
mutexes, this is no longer justified. Memory constrained applications
should use the self-contained synchronization objects. Remove the
CONFIGURE_MAXIMUM_MRSP_SEMAPHORES configuration option. This has only an
impact on applications which use SMP and a large number of scheduler
instances.
Update #3833.
---
cpukit/include/rtems/confdefs.h | 26 ++++++++------------------
cpukit/include/rtems/rtems/semdata.h | 28 ++++++++++++++++++++++++++--
cpukit/include/rtems/score/mrsp.h | 2 +-
cpukit/include/rtems/score/mrspimpl.h | 11 +----------
testsuites/smptests/smpfatal03/init.c | 1 -
testsuites/smptests/smpmrsp01/init.c | 1 -
testsuites/smptests/smpscheduler02/init.c | 1 -
testsuites/sptests/spmrsp01/init.c | 1 -
testsuites/tmtests/tmfine01/init.c | 2 --
9 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index cbcd1f98c2..3f949b2cfa 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -2000,22 +2000,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#define CONFIGURE_MAXIMUM_SEMAPHORES 0
#endif
-/*
- * This macro is calculated to specify the memory required for
- * Classic API Semaphores using MRSP. This is only available in
- * SMP configurations.
- */
-#if !defined(RTEMS_SMP) || \
- !defined(CONFIGURE_MAXIMUM_MRSP_SEMAPHORES)
- #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES 0
-#else
- #define _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES \
- CONFIGURE_MAXIMUM_MRSP_SEMAPHORES * \
- _Configure_From_workspace( \
- RTEMS_ARRAY_SIZE(_Scheduler_Table) * sizeof(Priority_Control) \
- )
-#endif
-
#ifndef CONFIGURE_MAXIMUM_MESSAGE_QUEUES
/**
* This configuration parameter specifies the maximum number of
@@ -2502,7 +2486,6 @@ struct _reent *__getreent(void)
_CONFIGURE_TASKS, _CONFIGURE_TASKS) + \
_CONFIGURE_MEMORY_FOR_TASKS( \
_CONFIGURE_POSIX_THREADS, _CONFIGURE_POSIX_THREADS) + \
- _CONFIGURE_MEMORY_FOR_MRSP_SEMAPHORES + \
_CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \
_CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
@@ -2786,7 +2769,10 @@ struct _reent *__getreent(void)
#endif
#if CONFIGURE_MAXIMUM_SEMAPHORES > 0
- SEMAPHORE_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_SEMAPHORES );
+ SEMAPHORE_INFORMATION_DEFINE(
+ CONFIGURE_MAXIMUM_SEMAPHORES,
+ _CONFIGURE_SCHEDULER_COUNT
+ );
#endif
#if _CONFIGURE_TIMERS > 0
@@ -3171,6 +3157,10 @@ struct _reent *__getreent(void)
#warning "The CONFIGURE_NUMBER_OF_TERMIOS_PORTS configuration option is obsolete since RTEMS 5.1"
#endif
+#ifdef CONFIGURE_MAXIMUM_MRSP_SEMAPHORES
+ #warning "The CONFIGURE_MAXIMUM_MRSP_SEMAPHORES configuration option is obsolete since RTEMS 5.1"
+#endif
+
#ifdef CONFIGURE_MAXIMUM_POSIX_BARRIERS
#warning "The CONFIGURE_MAXIMUM_POSIX_BARRIERS configuration option is obsolete since RTEMS 5.1"
#endif
diff --git a/cpukit/include/rtems/rtems/semdata.h b/cpukit/include/rtems/rtems/semdata.h
index f5a8afcc87..497f786dfb 100644
--- a/cpukit/include/rtems/rtems/semdata.h
+++ b/cpukit/include/rtems/rtems/semdata.h
@@ -108,9 +108,32 @@ void _Semaphore_MP_Send_extract_proxy (
* This macro should only be used by <rtems/confdefs.h>.
*
* @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag
- * may be set).
+ * may be set).
+ * @param scheduler_count The configured scheduler count (only used in SMP
+ * configurations).
*/
-#define SEMAPHORE_INFORMATION_DEFINE( max ) \
+#if defined(RTEMS_SMP)
+#define SEMAPHORE_INFORMATION_DEFINE( max, scheduler_count ) \
+ typedef union { \
+ Objects_Control Object; \
+ Semaphore_Control Semaphore; \
+ struct { \
+ Objects_Control Object; \
+ MRSP_Control Control; \
+ Priority_Control ceiling_priorities[ scheduler_count ]; \
+ } MRSP; \
+ } Semaphore_Configured_control; \
+ OBJECTS_INFORMATION_DEFINE( \
+ _Semaphore, \
+ OBJECTS_CLASSIC_API, \
+ OBJECTS_RTEMS_SEMAPHORES, \
+ Semaphore_Configured_control, \
+ max, \
+ OBJECTS_NO_STRING_NAME, \
+ _Semaphore_MP_Send_extract_proxy \
+ )
+#else
+#define SEMAPHORE_INFORMATION_DEFINE( max, scheduler_count ) \
OBJECTS_INFORMATION_DEFINE( \
_Semaphore, \
OBJECTS_CLASSIC_API, \
@@ -120,6 +143,7 @@ void _Semaphore_MP_Send_extract_proxy (
OBJECTS_NO_STRING_NAME, \
_Semaphore_MP_Send_extract_proxy \
)
+#endif
/** @} */
diff --git a/cpukit/include/rtems/score/mrsp.h b/cpukit/include/rtems/score/mrsp.h
index bb06b6aa2f..c7805aef57 100644
--- a/cpukit/include/rtems/score/mrsp.h
+++ b/cpukit/include/rtems/score/mrsp.h
@@ -73,7 +73,7 @@ typedef struct {
/**
* @brief One ceiling priority per scheduler instance.
*/
- Priority_Control *ceiling_priorities;
+ Priority_Control ceiling_priorities[ RTEMS_ZERO_LENGTH_ARRAY ];
} MRSP_Control;
/** @} */
diff --git a/cpukit/include/rtems/score/mrspimpl.h b/cpukit/include/rtems/score/mrspimpl.h
index 45b1d1ce7d..a576bc42dc 100644
--- a/cpukit/include/rtems/score/mrspimpl.h
+++ b/cpukit/include/rtems/score/mrspimpl.h
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2014, 2019 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -31,7 +31,6 @@
#include <rtems/score/status.h>
#include <rtems/score/threadqimpl.h>
#include <rtems/score/watchdogimpl.h>
-#include <rtems/score/wkspace.h>
#ifdef __cplusplus
extern "C" {
@@ -302,13 +301,6 @@ RTEMS_INLINE_ROUTINE Status_Control _MRSP_Initialize(
return STATUS_INVALID_NUMBER;
}
- mrsp->ceiling_priorities = _Workspace_Allocate(
- sizeof( *mrsp->ceiling_priorities ) * scheduler_count
- );
- if ( mrsp->ceiling_priorities == NULL ) {
- return STATUS_NO_MEMORY;
- }
-
for ( i = 0 ; i < scheduler_count ; ++i ) {
const Scheduler_Control *scheduler_of_index;
@@ -524,7 +516,6 @@ RTEMS_INLINE_ROUTINE void _MRSP_Destroy(
{
_MRSP_Release( mrsp, queue_context );
_Thread_queue_Destroy( &mrsp->Wait_queue );
- _Workspace_Free( mrsp->ceiling_priorities );
}
/** @} */
diff --git a/testsuites/smptests/smpfatal03/init.c b/testsuites/smptests/smpfatal03/init.c
index a2021ce57e..c40194aacb 100644
--- a/testsuites/smptests/smpfatal03/init.c
+++ b/testsuites/smptests/smpfatal03/init.c
@@ -89,7 +89,6 @@ static void fatal_extension(
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MAXIMUM_TIMERS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
-#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
diff --git a/testsuites/smptests/smpmrsp01/init.c b/testsuites/smptests/smpmrsp01/init.c
index 6f00f688e4..815f7a0983 100644
--- a/testsuites/smptests/smpmrsp01/init.c
+++ b/testsuites/smptests/smpmrsp01/init.c
@@ -1777,7 +1777,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_TASKS (2 * CPU_COUNT + 2)
#define CONFIGURE_MAXIMUM_SEMAPHORES (MRSP_COUNT + 1)
-#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES MRSP_COUNT
#define CONFIGURE_MAXIMUM_TIMERS 1
#define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
diff --git a/testsuites/smptests/smpscheduler02/init.c b/testsuites/smptests/smpscheduler02/init.c
index e6480aa819..9fdd5b9076 100644
--- a/testsuites/smptests/smpscheduler02/init.c
+++ b/testsuites/smptests/smpscheduler02/init.c
@@ -427,7 +427,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_MAXIMUM_SEMAPHORES 2
-#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
/* Lets see when the first RTEMS system hits this limit */
#define CONFIGURE_MAXIMUM_PROCESSORS 64
diff --git a/testsuites/sptests/spmrsp01/init.c b/testsuites/sptests/spmrsp01/init.c
index de12713625..0d03f1dc83 100644
--- a/testsuites/sptests/spmrsp01/init.c
+++ b/testsuites/sptests/spmrsp01/init.c
@@ -327,7 +327,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_TASKS 2
#define CONFIGURE_MAXIMUM_SEMAPHORES 1
-#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
#define CONFIGURE_INIT_TASK_PRIORITY 2
diff --git a/testsuites/tmtests/tmfine01/init.c b/testsuites/tmtests/tmfine01/init.c
index 21e6aff6f5..1fe7c22d83 100644
--- a/testsuites/tmtests/tmfine01/init.c
+++ b/testsuites/tmtests/tmfine01/init.c
@@ -816,8 +816,6 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_SEMAPHORES (1 + CPU_COUNT)
-#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES CPU_COUNT
-
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES CPU_COUNT
#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
--
2.16.4
More information about the devel
mailing list