On Fri, 2007-11-02 at 15:31 -0400, Robert Dewar wrote:
> Olivier Galibert wrote:

> There are lots of cases where global thread specific variables
> are useful in practice, ask anyone who has programmed real world
> large scale real time embedded programs.

No. And I have done just that myself. There is a use for 
hackery, for example profiling, debugging, etc.

Otherwise .. well the major real time code I did work on
had a big effort in place to *eliminate* all singletons
and static variables because they caused huge problems
generalising the code. Millions of lines of badly designed C++.

In fact, it is the other way around: for SMALL programs running
on tiny processors, global storage has to be used sometimes
because of the limitations of the processor. For example
I wrote lots of assembler for the 6802 microcontroller,
which doesn't allow you to *access* the subroutine stack.

>  One obvious example is
> the stack limit for checking stack overflow on subprogram entry.

Not required if the stack limit is stored in the stack itself.
The fact that this is hard to arrange just shows you AGAIN
there is badly designed interface somewhere along the line.

Felix pthreads record the stack base and stack pointer,
which is used for a conservative scan of the stack by the
garbage collector.. guess what? No static variables.
There's no stack limit check, but that would be easy to
add to the code. (but I think the way you'd do this
in Linux code would be to use mmap() and an invalid
block: AFAIK that's what Ocaml does, so the young
heap allocator is a SINGLE register increment .. this
is rather fast .. :)

-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

Reply via email to