Re: TLS - implementing linux one in fbsd
- From: David Xu <davidxu@xxxxxxxxxxx>
- Date: Wed, 21 Jun 2006 18:12:23 +0800
Divacky Roman wrote:
There is no such standard that a kernel must implement it in that way,The M:N and 1:1 threading in FreeBSD use different mechanisms to
implement TLS, M:N implements it in userland, while 1:1 implements it in kernel. the thr_new or thr_create are used for 1:1 threading, right now libthr uses thr_new to atomically setup a thread, this includes,
storing TID, setting TLS, and maybe signal mask( not implemented ) ,
cpu affinity mask etcs(not implemented), scheduling scope, in one word,
it is intended to map most part of pthread_attr into kernel world.
but on the kernel level the implementation must be the same.. I mean the
mangling of %gs. right?
we happens to implement it in kernel with GDT, before this, thread
libraries were using LDT. The offical TLS standard only defined ABI
in userspace: http://people.redhat.com/drepper/tls.pdf
M:N thread library only set GDT entry once, for Variant II TLS (x86),
the userland scheduler just replaces some pointers in TCB, it does
not have to set TLS via syscall later. but 1:1 thread library will
just let kernel context switch code to update it for next thread.
You can try, but the thr_xx syscalls were not designed to implement
well.. in linux the thread creation and setting up the tls is done using
separate syscalls. I plan to extend clone() syscall to use thr_create() or
thr_new() (if the flags tell me its thread) but I am afraid I'l have to modify
those syscalls to not to setup TLS (some flag) because linux wants to set it
separately.
linux clone() syscall, they are only used by libthr to implement 1:1
threading.
we don't save childtid pointer and clear it at thread exiting time likeI think it is used for futex, and the childtid is use to implement
pthread_join and garbage collection in thread library, the parent tid
pointer (if I recall correctly) is used by parent thread to retrieve
child tid.
this is the next step... I think all the magic is done in their libc (or
somewhere) and I basically just need to malloc some space for this info
and clear/set it on proces creation/exit
Linux did, we use thr_exit() which passes a pointer to let kernel
write a value into the address, this lets libthr's garbage collection
code work. the thr syscalls may be extented to save childtid pointer
somewhere in kernel by adding another flag, and clear it to zero when thread is exiting like Linux did.
the cpu_set_user_tls() is then what I need I think... maybe some modificationsRight.
needed but it shuold be basiscally the thing.
the linux syscall set_thread_area() just loads GDT with that info.. thats the
same like ours cpu_set_use_tls(), right?
thnx for your information!
roman
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- References:
- TLS - implementing linux one in fbsd
- From: Divacky Roman
- Re: TLS - implementing linux one in fbsd
- From: David Xu
- Re: TLS - implementing linux one in fbsd
- From: Divacky Roman
- TLS - implementing linux one in fbsd
- Prev by Date: Re: TLS - implementing linux one in fbsd
- Next by Date: Alternate toolchain
- Previous by thread: Re: TLS - implementing linux one in fbsd
- Next by thread: Tester needed, picture heavy webserver preferred.
- Index(es):
Relevant Pages
|