Re: Q: Thread local storage, thread IDs

cd_smith@ou.edu
Tue, 27 Jul 1999 14:34:33 -0500 (CDT)


On Tue, 27 Jul 1999, [iso-8859-1] Jörg Pleumann wrote:
> The problem is, but I forgot to mention this in the original mail, that
> I can't make use of external libraries at all. There are some linker
> problems that can't be solved right now, so everything I do has to be
> based on system calls (int 0x80) alone. It would be very helpful to know
> *how* PThreads implements this, though. I guess I'll have a look at the
> source code...

You mean you can't use libc? Are you sure that it's easier to reimplement
all the stuff from libc rather than just fix your link problem? But if
you do want to reimplement libc, then yes, the best way is probably to
grab libc and steal the code wholesale. (Assuming, of course, that the
result will be GPLed.) Reimplementing everything will almost assuredly
give you a less reliable product with more bugs.

> I need 1-based thread IDs because the thread local storage mechanism
> implemented in the Pascal compiler run-time library expects 1-based IDs
> for a simple lookup of a thread variable's value in a table.

Then, like I said, the only reasonable way to do this is to manage your
own thread identification using a global variable and a mutex. It's
ridiculous to ask the kernel to give you the specific thread numbering
scheme that you want just because another operating system does so. You
can't change every OS you ever port your program to.

> I could change this, of course, but I don't want to make more changes to
> the original RTL than absolutely necessary.

Part of porting is changing pieces of code that make non-portable
assumptions. Sorry, but it goes with the territory.

Chris Smith <cd_smith@ou.edu>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/