[rtems commit] Optional POSIX Mutex initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:33:09 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Dec 14 16:31:44 2015 +0100

Optional POSIX Mutex initialization

Update #2408.

---

 cpukit/posix/include/rtems/posix/muteximpl.h | 11 ++---------
 cpukit/posix/src/mutex.c                     | 13 ++++++++++++-
 cpukit/sapi/src/posixapi.c                   |  2 --
 cpukit/score/include/rtems/sysinit.h         |  1 +
 testsuites/sptests/spsysinit01/init.c        | 17 +++++++++++++++++
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/muteximpl.h b/cpukit/posix/include/rtems/posix/muteximpl.h
index f4c6c68..c1fab0c 100644
--- a/cpukit/posix/include/rtems/posix/muteximpl.h
+++ b/cpukit/posix/include/rtems/posix/muteximpl.h
@@ -31,12 +31,12 @@ extern "C" {
  *  The following defines the information control block used to manage
  *  this class of objects.
  */
-POSIX_EXTERN Objects_Information  _POSIX_Mutex_Information;
+extern Objects_Information _POSIX_Mutex_Information;
 
 /**
  *  The default mutex attributes structure.
  */
-POSIX_EXTERN pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
+extern pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
 
 /**
  *  This array contains a mapping from Score Mutex return codes to
@@ -45,13 +45,6 @@ POSIX_EXTERN pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
 extern const int _POSIX_Mutex_Return_codes[CORE_MUTEX_STATUS_LAST + 1];
 
 /**
- *  @brief POSIX Mutex Manager Initialization
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Mutex_Manager_initialization(void);
-
-/**
  *  @brief POSIX Mutex Allocate
  *
  *  This function allocates a mutexes control block from
diff --git a/cpukit/posix/src/mutex.c b/cpukit/posix/src/mutex.c
index 89e5b84..ef56d0a 100644
--- a/cpukit/posix/src/mutex.c
+++ b/cpukit/posix/src/mutex.c
@@ -24,11 +24,16 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/score/coremuteximpl.h>
 #include <rtems/score/watchdog.h>
 #include <rtems/posix/muteximpl.h>
 #include <rtems/posix/priorityimpl.h>
 
+Objects_Information _POSIX_Mutex_Information;
+
+pthread_mutexattr_t _POSIX_Mutex_Default_attributes;
+
 /*
  *  _POSIX_Mutex_Manager_initialization
  *
@@ -40,7 +45,7 @@
  *  Output parameters:  NONE
  */
 
-void _POSIX_Mutex_Manager_initialization(void)
+static void _POSIX_Mutex_Manager_initialization(void)
 {
   pthread_mutexattr_t *default_attr = &_POSIX_Mutex_Default_attributes;
 
@@ -77,3 +82,9 @@ void _POSIX_Mutex_Manager_initialization(void)
 #endif
   );
 }
+
+RTEMS_SYSINIT_ITEM(
+  _POSIX_Mutex_Manager_initialization,
+  RTEMS_SYSINIT_POSIX_MUTEX,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index 9277c93..da2b42b 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -34,7 +34,6 @@
 #include <rtems/posix/barrierimpl.h>
 #include <rtems/posix/config.h>
 #include <rtems/posix/mqueueimpl.h>
-#include <rtems/posix/muteximpl.h>
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/rwlockimpl.h>
@@ -62,7 +61,6 @@ void _POSIX_API_Initialize(void)
   _POSIX_Key_Manager_initialization();
 
   #ifdef RTEMS_POSIX_API
-    _POSIX_Mutex_Manager_initialization();
     _POSIX_Message_queue_Manager_initialization();
     _POSIX_Semaphore_Manager_initialization();
     _POSIX_Timer_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 9d1e59e..1ca95a1 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -45,6 +45,7 @@ extern "C" {
 #define RTEMS_SYSINIT_POSIX_SIGNALS              000360
 #define RTEMS_SYSINIT_POSIX_THREADS              000361
 #define RTEMS_SYSINIT_POSIX_CONDITION_VARIABLE   000362
+#define RTEMS_SYSINIT_POSIX_MUTEX                000363
 #define RTEMS_SYSINIT_POSIX_CLEANUP              00036a
 #define RTEMS_SYSINIT_IDLE_THREADS               000380
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 87d0c32..39c4fbe 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -29,6 +29,7 @@
 #include <rtems/extensionimpl.h>
 #ifdef RTEMS_POSIX_API
 #include <rtems/posix/condimpl.h>
+#include <rtems/posix/muteximpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/pthreadimpl.h>
 #endif /* RTEMS_POSIX_API */
@@ -89,6 +90,8 @@ typedef enum {
   POSIX_THREADS_POST,
   POSIX_CONDITION_VARIABLE_PRE,
   POSIX_CONDITION_VARIABLE_POST,
+  POSIX_MUTEX_PRE,
+  POSIX_MUTEX_POST,
   POSIX_CLEANUP_PRE,
   POSIX_CLEANUP_POST,
 #endif /* RTEMS_POSIX_API */
@@ -377,6 +380,18 @@ LAST(RTEMS_SYSINIT_POSIX_CONDITION_VARIABLE)
   next_step(POSIX_CONDITION_VARIABLE_POST);
 }
 
+FIRST(RTEMS_SYSINIT_POSIX_MUTEX)
+{
+  assert(_POSIX_Mutex_Information.maximum == 0);
+  next_step(POSIX_MUTEX_PRE);
+}
+
+LAST(RTEMS_SYSINIT_POSIX_MUTEX)
+{
+  assert(_POSIX_Mutex_Information.maximum != 0);
+  next_step(POSIX_MUTEX_POST);
+}
+
 static size_t user_extensions_pre_posix_cleanup;
 
 FIRST(RTEMS_SYSINIT_POSIX_CLEANUP)
@@ -506,6 +521,8 @@ static void Init(rtems_task_argument arg)
 
 #ifdef RTEMS_POSIX_API
 
+#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1
+
 #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
 
 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1



More information about the vc mailing list