<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div apple-content-edited="true">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.
</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">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.</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">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.</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">So, it is efficient :).</div>
<br><div><div>On May 10, 2013, at 5:22 PM, <a href="mailto:mika@async.caltech.edu">mika@async.caltech.edu</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Candara; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">This is just one data point, but I remember testing the performance of thread locals<br>on pthreads, probably on an old FreeBSD system, and the performance was horrendously<br>bad. There was a system call involved in obtaining the pointer to the thread-local<br>area. I was had some clever algorithms I wanted to use thread locals for (since you<br>can do all sorts of things without locks then), but I gave up on it since it was way<br>more expensive than a lock on that system...<br><br> Mika</span></blockquote></div><br></body></html>