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: __libc_single_threaded design


* Ondrej Bilka:

>> __libc_single_threaded can be implemented such that
>> its value only changes when the application is
>> single threaded, which means normal non-atomic read
>> access is valid, it can be a plain _Bool or int
>> and it's 100% reliable when the read value is 1.
>>
>> a thread count variable can change asynchronously
>> so users need atomic access, possibly requiring
>> libatomic to get linked in even if it's only used
>> for single-thread check, and if the value is >1
>> the meaning is unclear since it can change async.
>
> Then better way is to introduce bool if thread was created to fix 
> design mistake there.

The flag is called __libc_single_threaded (now:
pthread_single_threaded_np_ to convey that if it is true, the process is
definitely single-threaded.  If it false, it might be multi-threaded, or
we just might not know (as in a secondary namespace, or after static
dlopen).

Thanks,
Florian


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