Re: feature tests for pthreads implementation and configuration?



In article <1143145375.368361.103690@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<loic-dev@xxxxxxx> wrote:
Hi Mikael,

Is there a way to query Linux' pthreads about:
1. is it LinuxThreads or NPTL?
2. if LinuxThreads, for which kernel version was it configured?

Yes. Pls look at:
http://kasperd.net/~kasperd/comp.os.linux.development.faq#nptl

Thanks for this pointer.

Our problem is that a multi-threaded application we're developing
(a complex programming language implementation) is malfunctioning
when compiled against FC3's pthreads on x86 or amd64 (which seem
to be LinuxThreads configured for really old Linux kernels) while
it works fine when compiled against FC4's NPTL pthreads. (It also
works fine on Solaris9/x86.)

AFAIK, FC3 uses NPTL by default. There's perhaps a bug in that
particular NPTL version.

Actually I failed to consider that I ran FC3 with kernel 2.6.16 and
FC4 with an earlier RH 2.6 kernel. It turns out that the issue
comes from the 2.6.16 kernel, not FC3-vs-FC4 pthreads. (And I did
get NPTL with FC3; I looked at the wrong place and found the fallback
LinuxThreads code instead of the NPTL code it actually used.)

The issue is that kernel 2.6.16 clears a new thread's sigaltstack
settings (as per SUSv3) while previous kernels and apparently also
Solaris 9/x86 preserved it. That caused SIGFPEs in our threads to
be delivered on the current stack (a big no-no in our runtime system)
instead of the alt stack, causing memory corruption and SIGSEGVs.

The simple solution was to have each thread allocate and install
its own alt stack before starting running application code.
--
Mikael Pettersson (mikpe@xxxxxxxxx)
Computing Science Department, Uppsala University
.



Relevant Pages

  • Re: Does pthreads in Linux create user or kernel space threads?
    ... using getconf in shell gave me NPTL 0.60 ... advantage of substantial changes in the 2.6 kernel to provide an application API that's compatible with the POSIX thread standard behavior. ... Before all that, Linuxthreads provided a rough semblance of POSIX compatibility if you were careful, but with substantial overhead and reliance on a manager thread. ...
    (comp.programming.threads)
  • Re: Thread and process dentifiers (CPU affinity, kill)
    ... glibc contains both LinuxThreads and NPTL. ... > depending on if the currently running kernel supports NTPL. ...
    (Linux-Kernel)
  • Re: Some threading questions from nptl newbie
    ... I've heard NPTL is the newest and greatest threading implementation ... To use the older library LinuxThreads, ... > discovered the server it's meant to run on is running a 2.4 kernel. ...
    (comp.programming.threads)
  • Re: LD_FUNDAMENTALLY_FLAWED
    ... > This is to get it to enable the use of linuxthreads 2.4.19 floating stacks. ... > Either way I have either icluded something in the kernel that I shouldn't ... > something out that's causing the kernel to ignore the LD_ environment ... includes the NPTL which is a new threading library. ...
    (alt.os.linux.redhat)
  • Re: Threads and processes on Linux
    ... task runs in the same memory space as the parent task. ... LinuxThreads and/or older 2.4.x kernel. ... _abstraction_ provided by NPTL: ... > the spawned thread), the spwaned thread also seems to terminate. ...
    (comp.os.linux.misc)