Is any difference between default and static mutex initialization?
Robert White wrote: > Venkat Ganti wrote: > > > I want to know whether there is any difference between the following > > two mutex initializations using pthreads > > > > 1. > > > > pthread_mutex_t mp = PTHREAD_MUTEX_INITIALIZER; > > > > 2. > > > > pthread_mutex_t mp; > > pthread_mutex_init (&mp, NULL); > > > > In this the allocaled memory is zero. > > > > An other way that these two may be different (in addition to the ones > mentioned by Dave B. in his reply) is that the latter form can have > different meaning as the program progresses because the default mutex > behavior of a program can be changed with the set-attribute calls (I > forget the exact call) when the attribute sepsified in the call is the > NULL pointer. You can’t change the attribute values of the NULL attributes object. When you initialize a mutex using NULL, you’re asking for default attributes — those MUST ALWAYS be the same attributes that will be used by a statically initialized mutex. It doesn’t (and can’t) matt