This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] New functions pthread_[sg]etattr_default_np for default thread attributes


On Tue, 2013-06-11 at 17:06 -0700, Roland McGrath wrote:
> > +  else
> > +    {
> > +      lll_lock (__default_pthread_attr_lock, LLL_PRIVATE);
> > +      size = __default_pthread_attr.stacksize;
> > +      lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE);
> > +    }
> 
> The lock isn't really needed for a single word fetch that doesn't need to
> be synchronized with anything else.

I agree that locking might not be the most efficient kind of
synchronization, but unless reading the stacksize field will not be
concurrent with other write accesses, we do need some kind of
synchronization / atomic access.

At least, this should be an atomic access with relaxed memory order (ie,
like in C11), or at very least a comment to add that in the future.
Making this an explicitly atomic access will tell users that this is in
fact concurrent code, and it will make sure the compiler handles this
access properly (I believe this isn't a volatile already, or is it?)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]