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: Dummy pthread functions in libc considered harmful


On Thu, Sep 03, 2015 at 09:14:14AM +0200, Andreas Schwab wrote:
> "Carlos O'Donell" <carlos@redhat.com> writes:
> 
> > Is there ever a safe way to transition from running unthreaded to
> > threaded if you are not using a full implementation of locks in libc.so?
> 
> As long as you have no "locked" mutexes while libpthread is being loaded
> (which installs the real pthread_mutex functions), there is no danger,
> since you cannot create new threads without libpthread being fully
> active.
> 
A requirement for no locked mutex isn't necessary. It simplifies things
as with it a functions could be nop.

It would definitely be possible to write single thread locks that
consistently setup structure, but it wouldn't be wise. It would make
harder mainainance of two different implementations.

Instead we should add single-thread path to locks and atomics.

Now when I looked assembly optimization we do leaves lot to be desired,
as we need branch for each operation. Instead we could branch only once
for each function to single and multithread versions.


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