Process local variable and debugging

Lex Spoon lex at cc.gatech.edu
Mon Feb 11 18:48:25 UTC 2002


"Lex Spoon" <lex at cc.gatech.edu> wrote:
> "Andreas Raab" <Andreas.Raab at gmx.de> wrote:
> > If you have as simple a model as Squeak has there is an even easier (and
> > more efficient) way of doing TLS. All you need is some slot in Process
> > which will hold an array of "Global Association -> current value". When
> > you switch between processes you exchange the globals with the current
> > value of the association, e.g., when you switch _from_ a process you
> > restore the old and remember the private values whereas if you switch
> > _to_ a process you restore the private and remember the global values.
> > Trivial to implement.
> > 
> > The advantage of this scheme is that the cost of using TLS is associated
> > exclusively with the process actually using them. If you switch between
> > processes not using TLS you don't do anything at all - if you switch
> > to/from a process making heavy use of it, you pay the price just as you
> > have to.
> > 
> 
> That's exactly how I implemented them with my Islands project in Squeak.
>  I also made most global variables into thread-specific variables,
> meaning the price got paid quite a lot.  :(  -Lex

Never mind, on a closer reading this isn't what I did.  I gave each
process a table of associations, but I updated variable lookup to look
in the per-process table.  A simple cache made these lookups run
tolerably fast.

The scheme was really very similar to dynamic method lookup, which is
especially neat if you name the variables "dynamically-bound variables"
instead of "thread-local variables".


-Lex



More information about the Squeak-dev mailing list