[M3devel] thread local storage, but in C pieces of runtime... (jay, tony?)

Dragiša Durić dragisha at m3w.org
Fri May 10 18:39:33 CEST 2013


AFAIK, Linux ABI uses dedicated register (one of segment registers) to access TLS. It's setting is part of context switch, and one is only supposed to use it read-only. No kernel space is involved in accessing, and was not since NPTL was introduced.

Old and FreeBSD does ring bells :). Linux pioneered lightweight processes/threads in free *nix world, and others followed. If your test was near enough in time to 2004-5-6, then probably it was a time when FreeBSD played catch-up.

Also, on Linux since 2004, uncontested lock is user-space only. It probably involves a barrier of some kind, but it is under 0.5microsecond in worst case, as opposed to 20-50microsecond for kernel space operation.

So, it is efficient :).

On May 10, 2013, at 5:22 PM, mika at async.caltech.edu wrote:

> This is just one data point, but I remember testing the performance of thread locals
> on pthreads, probably on an old FreeBSD system, and the performance was horrendously
> bad.  There was a system call involved in obtaining the pointer to the thread-local
> area.  I was had some clever algorithms I wanted to use thread locals for (since you
> can do all sorts of things without locks then), but I gave up on it since it was way
> more expensive than a lock on that system...
> 
>     Mika

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130510/c6a83820/attachment-0002.html>


More information about the M3devel mailing list