If you need it to be really fast and you don't have an MMU, you have
to dedicate a register to holding something unique about each thread -
either an id, or a pointer to a structure.
As I have programmable hardware, I quite easily can create a "register" (but same would not be saved by Linux when switching processes). But OTOH, if that is possible, a memory location would do the same: I would need to modify the scheduler code to update this memory location.

That's what TLS does on
many architectures.  You can do itself if you're willing to recompile
_everything_ (including libc etc.) telling GCC about the extra
register, but that's usually a bad idea.
Ooops :(
With an MMU it's possible to store different values at the same
address in each thread.  TLS on some architectures works like that.

With LinuxThreads you can use the portable pthreads method:
pthread_getspecific().  It's not as fast as TLS, but not slow either.
I'll take a look...

-Michael
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to