All Windows objects that are managed as HANDLES can easily be modified to have 
static initializer. A clean solution is attached to the question at 
stackoverflow:
http://stackoverflow.com/questions/3555859/is-it-possible-to-do-static-initialization-of-mutexes-in-windows

That being said I think having a static initializer for a synchronization 
object is a dangerous thing. It has many subtleties and too many hidden 
limitations. As an example they can only be used on the declaration of the 
object, and can't be safely used for locally static object (they must be 
global).

What are the instances in the Open MPI code where such a statically defined 
mutex need to be used before it has a chance of being correctly initialized?

  George.


On Jun 7, 2013, at 18:38 , "Jeff Squyres (jsquyres)" <jsquy...@cisco.com> wrote:

> Perhaps I was wrong -- I thought we had no static initializer because there 
> was no static initializer for mutexes in windows.  
> 
> 
> On Jun 7, 2013, at 9:28 AM, George Bosilca <bosi...@icl.utk.edu> wrote:
> 
>> Im curious to know why Windows support is to be blamed for the lack of such 
>> functionality?
>> 
>> George.
>> 
>> On Jun 7, 2013, at 18:08 , Jeff Squyres (jsquyres) <jsquy...@cisco.com> 
>> wrote:
>> 
>>> Nathan forgot to mention that we didn't have this before because of 
>>> Windows.  But now we don't have Windows support, so...
>>> 
>>> 
>>> On Jun 7, 2013, at 9:01 AM, "Hjelm, Nathan T" <hje...@lanl.gov> wrote:
>>> 
>>>> What: Add a static initializer for opal_mutex_t for both posix and solaris 
>>>> threads.
>>>> 
>>>> Why: Enables the use of opal locks that don't have to be OBJ_CONSTRUCT'ed.
>>>> 
>>>> When: This is a trivial addition but I would like some review/testing of 
>>>> the code (I don't have solaris). Setting timeout to Tuesday, June 11, 2013
>>>> 
>>>> 
>>>> diff --git a/opal/threads/mutex_unix.h b/opal/threads/mutex_unix.h
>>>> index 27528e6..28b1744 100644
>>>> --- a/opal/threads/mutex_unix.h
>>>> +++ b/opal/threads/mutex_unix.h
>>>> @@ -81,6 +81,25 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(opal_mutex_t);
>>>> * POSIX threads
>>>> ************************************************************************/
>>>> 
>>>> +#if !OPAL_ENABLE_MULTI_THREADS && OPAL_ENABLE_DEBUG
>>>> +#define OPAL_MUTEX_STATIC_INIT                      \
>>>> +  {                                                 \
>>>> +      .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
>>>> +      .m_lock_pthread = PTHREAD_MUTEX_INITIALIZER,  \
>>>> +      .m_lock_debug = 0,                            \
>>>> +      .m_lock_file = NULL,                          \
>>>> +      .m_lock_line = 0,                             \
>>>> +      .m_lock_atomic = 0                            \
>>>> +  }
>>>> +#else
>>>> +#define OPAL_MUTEX_STATIC_INIT                      \
>>>> +  {                                                 \
>>>> +      .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
>>>> +      .m_lock_pthread = PTHREAD_MUTEX_INITIALIZER,  \
>>>> +      .m_lock_atomic = 0                            \
>>>> +  }
>>>> +#endif
>>>> +
>>>> static inline int opal_mutex_trylock(opal_mutex_t *m)
>>>> {
>>>> #if OPAL_ENABLE_DEBUG
>>>> @@ -130,6 +149,25 @@ static inline void opal_mutex_unlock(opal_mutex_t *m)
>>>> * Solaris threads
>>>> ************************************************************************/
>>>> 
>>>> +#if !OPAL_ENABLE_MULTI_THREADS && OPAL_ENABLE_DEBUG
>>>> +#define OPAL_MUTEX_STATIC_INIT                      \
>>>> +  {                                                 \
>>>> +      .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
>>>> +      .m_lock_solaris = DEFAULTMUTEX,               \
>>>> +      .m_lock_debug = 0,                            \
>>>> +      .m_lock_file = NULL,                          \
>>>> +      .m_lock_line = 0,                             \
>>>> +      .m_lock_atomic = 0                            \
>>>> +  }
>>>> +#else
>>>> +#define OPAL_MUTEX_STATIC_INIT                      \
>>>> +  {                                                 \
>>>> +      .super = OPAL_OBJ_STATIC_INIT(opal_object_t), \
>>>> +      .m_lock_solaris = DEFAULTMUTEX,               \
>>>> +      .m_lock_atomic = 0                            \
>>>> +  }
>>>> +#endif
>>>> +
>>>> 
>>>> static inline int opal_mutex_trylock(opal_mutex_t *m)
>>>> {
>>>> 
>>>> _______________________________________________
>>>> devel mailing list
>>>> de...@open-mpi.org
>>>> http://www.open-mpi.org/mailman/listinfo.cgi/devel
>>> 
>>> 
>>> -- 
>>> Jeff Squyres
>>> jsquy...@cisco.com
>>> For corporate legal information go to: 
>>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>> 
>>> 
>>> _______________________________________________
>>> devel mailing list
>>> de...@open-mpi.org
>>> http://www.open-mpi.org/mailman/listinfo.cgi/devel
>> 
>> 
>> _______________________________________________
>> devel mailing list
>> de...@open-mpi.org
>> http://www.open-mpi.org/mailman/listinfo.cgi/devel
> 
> 
> -- 
> Jeff Squyres
> jsquy...@cisco.com
> For corporate legal information go to: 
> http://www.cisco.com/web/about/doing_business/legal/cri/
> 
> 
> _______________________________________________
> devel mailing list
> de...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/devel


Reply via email to