Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is any difference between default and static mutex initialization?

0
Posted

Is any difference between default and static mutex initialization?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123