tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

_lwp_setprivate and _lwp_makecontext



Hi all,
I'm working on Thread Locale Storage support for NetBSD and I am facing
an interesting issue with the libpthread integration. On i386 and AMD64,
TLS support uses the segment register %gs or %fs to load the thread
pointer. The location used as segment base is thread specific and stored
in the PCB. It is not part of ucontext_t and therefore _lwp_makecontext
can't store private in it. To work around this, I can think of three
options:

(1) Break ucontext_t and allow the private pointer as separate field

Pro: Integrates nicely with the other platforms and debugger
Contra: Lots of nasty interfaces to deal with in terms of compat.

(2) Add private as argument for _lwp_create as well.

Pro: logically fits well too, minimal amount of changes for libc and
libpthread.

(3) Defer calling _lwp_setprivate into the newly created thread.

Pro: no kernel / libc changes needed
Contra: might create complications with signal handlers etc


I'm personally favoring (2), but looking for input.

Joerg


Home | Main Index | Thread Index | Old Index