Good afternoon,

the io/wallclock/ static initializer currently runs after CYG_INIT_CLOCK. However, the I2C device that may control the clock, or the clock itself, may use mutexes. Therefore the initializer order must be _AFTER( CYG_INIT_THREADS).

I ran into this when I enabled assertions in eCos: the mutex in my I2C was used before the thread package was initialized, and this caused an assertion failure.

Patch attached. Is this format OK? I merged eCos into our SVN repository, so the diff format will be slightly different from cvs diff output.

Rutger Hofman
VU Amsterdam
Index: packages/io/wallclock/current/src/wallclock.cxx
===================================================================
--- packages/io/wallclock/current/src/wallclock.cxx     (revision 160)
+++ packages/io/wallclock/current/src/wallclock.cxx     (working copy)
@@ -80,7 +80,7 @@
 //-----------------------------------------------------------------------------
 // Local static variables
 
-static Cyg_WallClock wallclock_instance CYGBLD_ATTRIB_INIT_AFTER( 
CYG_INIT_CLOCK );
+static Cyg_WallClock wallclock_instance CYGBLD_ATTRIB_INIT_AFTER( 
CYG_INIT_THREADS );
 
 #ifndef CYGSEM_WALLCLOCK_SET_GET_MODE
 static cyg_uint32 epoch_ticks;
Index: packages/io/wallclock/current/ChangeLog
===================================================================
--- packages/io/wallclock/current/ChangeLog     (revision 153)
+++ packages/io/wallclock/current/ChangeLog     (working copy)
@@ -1,3 +1,7 @@
+2008-01-11  Rutger Hofman <[EMAIL PROTECTED]>
+       * src/wallclock.cxx: using a mutex, here or in the I2C code,
+       requires that the static initializer runs after CYG_INIT_THREADS.
+
 2007-01-14  Gary Thomas  <[EMAIL PROTECTED]>
 
        * src/wallclock.cxx: Use a mutex for exclusion during get/set

Reply via email to