digitalmars.D - Re: Is D right for me?
- Sean Kelly <sean invisibleduck.org> Oct 13 2010
Jacob Carlborg Wrote:On 2010-10-13 07:17, Walter Bright wrote:Denis Koroskin wrote:Either way, it needs some language support, because currently TLS implemented on compiler level rather than library level. I proposed this change in past, but no one responded.
Using TLS needs operating system support, and there's special linker support for it and the compiler has to generate TLS references in certain ways in order for it to work. There is no such support in OSX for TLS, and it is done manually by the library. However, TLS access is 10 times slower than on Linux/Windows. Without doing TLS in the operating system standard way, you tend to get hosed if you link with a shared library/DLL that has TLS.
I don't know how you have implemented TLS on Mac OS X but it does support TLS via the Posix API pthreads. This is the only page from Apple's documentation I could find for now (I'm certain I've seen a better page) http://developer.apple.com/macosx/multithreadedprogramming.html .
Using the Posix API here is tricky because it isn't always documented where the memory resides, so enabling GC scanning of it can be tricky. Also, default initialization gets a bit weird, etc. What we really need is for OSX to support the __thread storage class. We're not alone though, so I think it's likely we'll see it implemented in a future release.
Oct 13 2010