#1901 closed defect (fixed)

Global C++ constructors with MP configuration

Reported by: Sebastian Huber Owned by: Joel Sherrill
Priority: normal Milestone: 4.11
Component: score Version: 4.11
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

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?

Change History (2)

comment:1 Changed on Sep 9, 2011 at 10:25:38 AM by Sebastian Huber

Resolution: fixed
Status: newclosed

Fixed on CVS head.

comment:2 Changed on Nov 24, 2014 at 6:58:28 PM by Gedare Bloom

Version: HEAD4.11

Replace Version=HEAD with Version=4.11 for the tickets with Milestone >= 4.11

Note: See TracTickets for help on using tickets.