libgcj and the NPTL posix threads implementation

Michael Koch konqueror@gmx.de
Fri Feb 27 15:48:00 GMT 2004


Am Freitag, 27. Februar 2004 16:39 schrieb Anthony Green:
> Recent glibc based systems are often bundled with a new posix threads
> implementation called NPTL (vs the old linuxthreads implementation).
>
> I believe that the NPTL code has been shaken out enough now that we
> should start taking advantage of it.
>
> For instance, our posix-threads.h says:
>   // For compatibility, simplicity, and correctness, we do not use
> the native // pthreads recursive mutex implementation, but simulate
> them instead.
>
> It looks like NPTL contains a working version of recursive mutexes.
> Using them will save a lot of work in what is probably one of our
> most frequently called runtime function (at least one additional
> function call and some tens of
> instructions).
>
> I propose we just...
> #define _Jv_Mutex_t pthread_mutex_t
> ...on NPTL enabled systems, and make appropriate changes.
>
> The one catch is _Jv_MutexCheckMonitor(_Jv_Mutex_t *), which is a
> sanity checker and wants to look at the mutex owner.  Is it safe to
> ignore this?
>
>
> We define SLOW_PTHREAD_SELF for many Linux systems.  If you look in
> posix-threads.h, this forces us to fall back on a clever caching
> scheme.  However, for x86 Linux I believe _Jv_ThreadSelf may now be
> implemented as a single machine instruction (a recent minor ABI
> change to support thread local storage (TLS) makes this possible).
>
>
> I'm certain there are other areas where we may take advantage of the
> NPTL and TLS given a few more minutes of looking.  However, I'm not
> sure how best to handle the configury aspects.  Do we want a global
> NPTL test and #define?   This seems like the simplest approach.  I'm
> not even sure there's an easy way to detect NPTL-ness.  Perhaps we
> should just look at at the glibc version and make an assumption. 
> Opinions?

Would looking at glibc version be enough ? I know at least on Debian 
based systems NPTL/TLS only works with Linux kernel 2.6.x but not 2.4.x 
or older systems.


Michael



More information about the Java mailing list