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 (was: Re: libpthread removal project)


> __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.

Correct code needs to be slower than necessary as it needs to handle
multithreaded->singlethreaded transition and lot of programmers assume
this transition won't happen.


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