[Bug 1901] New: Global C++ constructors with MP configuration
    bugzilla-daemon at rtems.org 
    bugzilla-daemon at rtems.org
       
    Tue Aug 23 09:21:55 UTC 2011
    
    
  
https://www.rtems.org/bugzilla/show_bug.cgi?id=1901
           Summary: Global C++ constructors with MP configuration
           Product: RTEMS
           Version: HEAD
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: normal
          Priority: P3
         Component: cpukit
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: sebastian.huber at embedded-brains.de
The global C++ constructors are supposed to execute within the context of the
first initialization thread.  In the MP configuration the MP thread will
execute before the initialization threads.  In this case the current logic
leads to an execution of the global C++ constructors within the MP thread. 
This may result in dead locks.
Please have a look at this patch:
Index: cpukit/score/src/threadhandler.c
===================================================================
--- cpukit/score/src/threadhandler.c    (revision 5237)
+++ cpukit/score/src/threadhandler.c    (working copy)
@@ -88,8 +88,8 @@
   ISR_Level  level;
   Thread_Control *executing;
   #if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
-    static char doneConstructors;
-    char doneCons;
+    static bool doneConstructors;
+    bool doCons;
   #endif
   executing = _Thread_Executing;
@@ -110,8 +110,10 @@
   _ISR_Set_level(level);
   #if defined(EXECUTE_GLOBAL_CONSTRUCTORS)
-    doneCons = doneConstructors;
-    doneConstructors = 1;
+    doCons = !doneConstructors
+      && _Objects_Get_API( executing->Object.id ) != OBJECTS_INTERNAL_API;
+    if (doCons)
+      doneConstructors = true;
   #endif
   #if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
@@ -143,7 +145,7 @@
      *  in any configuration I know of and it generates a warning on every
      *  RTEMS target configuration.  --joel (12 May 2007)
      */
-    if (!doneCons) /* && (volatile void *)_init) */ {
+    if (doCons) /* && (volatile void *)_init) */ {
       INIT_NAME ();
       #if defined(RTEMS_SMP)
Is it better to use the RTEMS_MULTIPROCESSING define to make this conditional?
-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.
    
    
More information about the bugs
mailing list