In article <20120822170050.gj2...@homeworld.netbsd.org>, Emmanuel Dreyfus <m...@netbsd.org> wrote: >-=-=-=-=-=- > >Here is an updated patch for sorting out swapcontext with libpthread, >with documentation and test cases. > >I would appreciate feedback on LWP_PRESERVETLS flag to _lwp_create(). >This tells the kernel that the TLS base register will be used by >libpthread and that setcontext() should leave it untouched. > >This is done in kernel because it seems to be the easiest way: >another approach would be to have libpthread overriding setcontext(), >but that seems a bad choice: after unsetting _UC_TLSBASE it needs >to call the real setcontext, which means doing a system call from >libpthread. That looks wrong.
Why do you say that? pthread_cancelstub.c does exactly this (wrapping a syscall and calling it) all the time. I don't think we should be getting the kernel involved with this. christos