Waldek Hebisch wrote:
There is no need to eliminate variables. GCC (starting from version 3.3) supports thread local variables. At least on Linux access to thread local variables is reasonably cheap (only slightly more expensive then nomal variables). So, one can turn IOResult into thread local variable and use it as before.
Ah, good! Still, IMHO, we should check which RTS variables don't need to be thread-local to avoid wasting effort. I.e., those that are initialized only once (possibly taking care of the initalization).
And we need to consider external side-effects, i.e. does it make sense to have thread-local `Input', each reading into its own, thread-local buffer? I suppose not, so we probably do need other synchronisation mechanisms in the RTS.
Of course, for this also GPC should support thread local variables. ATM GPC does not support thread local variables, mainly because we want to have the same feature set with all backends and older backends (IIRC 3.2 and earlier) do not support them.
Same feature set where reasonably possible. As earlier GCC versions are already obsolescent (I don't want to drop them immediately, but is there any real need for versions before 3.4 anymore?), we should not waste any effort back-porting things. An error message when trying to use them with an earlier backend should be clear enough, so those who need threads will know they have to use 3.3 or newer.
BTW, how are they activated? As a special attribute or something like this? I.e., special handling in the frontend required only at declaration time, or also on usage?
Also, thread safety may have considerable cost on single-threaded programs. For example Java and glibc try to be thread safe, and in effect some single-threaded run about 5 times slower than thread unsafe versions. I think that we shall pay the price, but I do not know what other think.
I don't agree, i.e. we should be able to turn it on when needed only. As I wrote, this probably requires two versions of the RTS to be compiled and some options etc., but this seems a smaller price to pay in the end.
Frank