Is D Dead?

IGotD- nise at nise.com
Thu Sep 16 10:04:22 UTC 2021


On Thursday, 16 September 2021 at 05:59:57 UTC, Araq wrote:
>
> To emulate TLS allocate a block of memory at the top/bottom of 
> your stack and use a bitmask on your stack pointer in order to 
> access it. No OS support required.

The TLS standard requires the OS to initialize the TLS area for 
each new thread so OS support is required. You have size 
constraints when you put TLS on the stack. If some bright 
programmer decides to have several megabytes of data as TLS, this 
is not an option but this is a fringe case though. If your OS 
supports shared libraries, the implementation becomes much more 
complicated.

The C++ standard doesn't support contructors/deconstuctors in the 
TLS area, only simple zero and copy initialization is supported. 
D makes this more complicated as it supports 
contructors/deconstuctors in TLS. Because of this TLS increases 
the time for spawning new threads, especially in D and this 
regardless if the thread use any TLS variable or not.

If you have a single thread program, you can use the GCC TLS 
emulation.

The TLS standard feels rushed and shoved in with a shoehorn. 
There are several fringe cases to deal with.


More information about the Digitalmars-d mailing list