This is the mail archive of the libc-alpha@sources.redhat.com 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]

Using clone with glibc


The project that I am working on depends on access to raw kernel
threads (i.e., not through pthreads).  On linux, we use clone to obtain
such threads.  Traditionally, this was quite straightforward, but
recent versions of glibc have made this increasingly more complicated.
I'm hoping that some of the knowledgeable people on this list can
suggest some ways of dealing with the issues involved.

It seems unavoidable that a program creating threads with clone must
allocate TLS for the new thread, otherwise errno (and perhaps other
internal libc data) is shared unsafely between threads.  This requires
setting up a thread pointer (messing with gs on x86, for instance), and
getting dl_allocate_tls to do the heavy lifting.  Am I correct in
believing that all of this is necessary?

More problematic, however, are various bits of the pthread descriptor
that libc relies upon having at fixed offsets from the thread pointer.
At the application level, I don't know how big the thread descriptor
is, nor how to initialize it.  There doesn't seem to be a function that
does this sort of minimal initialization.  Does one exist, or is there
an easier way to use clone threads with glibc?


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