[rtems commit] Optional POSIX Threads initialization

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


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Dec 11 10:47:22 2015 +0100

Optional POSIX Threads initialization

Update #2408.

---

 cpukit/posix/include/rtems/posix/pthreadimpl.h |  9 +--------
 cpukit/posix/src/killinfo.c                    | 12 ++----------
 cpukit/posix/src/pthread.c                     | 11 ++++++++++-
 cpukit/sapi/src/posixapi.c                     |  2 --
 cpukit/score/include/rtems/sysinit.h           |  1 +
 testsuites/sptests/spsysinit01/init.c          | 21 +++++++++++++++++++++
 6 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/pthreadimpl.h b/cpukit/posix/include/rtems/posix/pthreadimpl.h
index f95ac9c..9aff71c 100644
--- a/cpukit/posix/include/rtems/posix/pthreadimpl.h
+++ b/cpukit/posix/include/rtems/posix/pthreadimpl.h
@@ -44,7 +44,7 @@ extern "C" {
  * The following defines the information control block used to manage
  * this class of objects.
  */
-POSIX_EXTERN Thread_Information  _POSIX_Threads_Information;
+extern Thread_Information _POSIX_Threads_Information;
 
 /**
  * This variable contains the default POSIX Thread attributes.
@@ -61,13 +61,6 @@ extern pthread_attr_t _POSIX_Threads_Default_attributes;
 extern void (*_POSIX_Threads_Initialize_user_threads_p)(void);
 
 /**
- * @brief POSIX threads manager initialization.
- *
- * This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Threads_Manager_initialization(void);
-
-/**
  * @brief Copy POSIX Thread attribute structure.
  *
  * This routine copies the attr2 thread attribute structure
diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c
index 7f4adc7..a29a8e6 100644
--- a/cpukit/posix/src/killinfo.c
+++ b/cpukit/posix/src/killinfo.c
@@ -198,16 +198,8 @@ int killinfo(
       continue;
 
     the_info = _Objects_Information_table[ the_api ][ 1 ];
-
-    #if defined(RTEMS_DEBUG)
-      /*
-       *  This cannot happen in the current (as of June 2009) implementation
-       *  of initialization but at some point, the object information
-       *  structure for a particular manager may not be installed.
-       */
-      if ( !the_info )
-        continue;
-    #endif
+    if ( !the_info )
+      continue;
 
     maximum = the_info->maximum;
     object_table = the_info->local_table;
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index ee7da11..691dfc3 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -26,6 +26,7 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/score/apiext.h>
 #include <rtems/score/stack.h>
 #include <rtems/score/threadimpl.h>
@@ -43,6 +44,8 @@
 #include <rtems/score/cpusetimpl.h>
 #include <rtems/score/assert.h>
 
+Thread_Information _POSIX_Threads_Information;
+
 /*
  *  The default pthreads attributes structure.
  *
@@ -338,7 +341,7 @@ User_extensions_Control _POSIX_Threads_User_extensions = {
  *
  *  This routine initializes all threads manager related data structures.
  */
-void _POSIX_Threads_Manager_initialization(void)
+static void _POSIX_Threads_Manager_initialization(void)
 {
   #if defined(RTEMS_SMP) && defined(__RTEMS_HAVE_SYS_CPUSET_H__)
     const CPU_set_Control *affinity;
@@ -381,3 +384,9 @@ void _POSIX_Threads_Manager_initialization(void)
    *       Register the MP Process Packet routine.
    */
 }
+
+RTEMS_SYSINIT_ITEM(
+  _POSIX_Threads_Manager_initialization,
+  RTEMS_SYSINIT_POSIX_THREADS,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index 1c54b77..4cf5249 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -38,7 +38,6 @@
 #include <rtems/posix/muteximpl.h>
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
-#include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/rwlockimpl.h>
 #include <rtems/posix/timerimpl.h>
 #include <rtems/posix/semaphoreimpl.h>
@@ -64,7 +63,6 @@ void _POSIX_API_Initialize(void)
   _POSIX_Key_Manager_initialization();
 
   #ifdef RTEMS_POSIX_API
-    _POSIX_Threads_Manager_initialization();
     _POSIX_Condition_variables_Manager_initialization();
     _POSIX_Mutex_Manager_initialization();
     _POSIX_Message_queue_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index a6cb32f..1da3b30 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -43,6 +43,7 @@ extern "C" {
 #define RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC     000349
 #define RTEMS_SYSINIT_CLASSIC_BARRIER            00034a
 #define RTEMS_SYSINIT_POSIX_SIGNALS              000360
+#define RTEMS_SYSINIT_POSIX_THREADS              000361
 #define RTEMS_SYSINIT_IDLE_THREADS               000380
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
 #define RTEMS_SYSINIT_BEFORE_DRIVERS             000500
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 328851d..3bbea9c 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -28,6 +28,7 @@
 #include <rtems/extensionimpl.h>
 #ifdef RTEMS_POSIX_API
 #include <rtems/posix/psignalimpl.h>
+#include <rtems/posix/pthreadimpl.h>
 #endif /* RTEMS_POSIX_API */
 #include <rtems/rtems/barrierimpl.h>
 #include <rtems/rtems/dpmemimpl.h>
@@ -81,6 +82,8 @@ typedef enum {
 #ifdef RTEMS_POSIX_API
   POSIX_SIGNALS_PRE,
   POSIX_SIGNALS_POST,
+  POSIX_THREADS_PRE,
+  POSIX_THREADS_POST,
 #endif /* RTEMS_POSIX_API */
   IDLE_THREADS_PRE,
   IDLE_THREADS_POST,
@@ -343,6 +346,18 @@ LAST(RTEMS_SYSINIT_POSIX_SIGNALS)
   next_step(POSIX_SIGNALS_POST);
 }
 
+FIRST(RTEMS_SYSINIT_POSIX_THREADS)
+{
+  assert(_POSIX_Threads_Information.Objects.maximum == 0);
+  next_step(POSIX_THREADS_PRE);
+}
+
+LAST(RTEMS_SYSINIT_POSIX_THREADS)
+{
+  assert(_POSIX_Threads_Information.Objects.maximum != 0);
+  next_step(POSIX_THREADS_POST);
+}
+
 #endif /* RTEMS_POSIX_API */
 
 FIRST(RTEMS_SYSINIT_IDLE_THREADS)
@@ -448,6 +463,12 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_TIMERS 1
 
+#ifdef RTEMS_POSIX_API
+
+#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
+
+#endif /* RTEMS_POSIX_API */
+
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
 #define CONFIGURE_STACK_CHECKER_ENABLED




More information about the vc mailing list