>>>>> "Gerd" == Gerd Moellmann <[EMAIL PROTECTED]> writes:

    Gerd> Raymond Toy <[EMAIL PROTECTED]> writes:
    >> I believe thread switching is slow because it has to copy the control
    >> (?)  stack on each switch.

    Gerd> Maybe you mean the "binding stack", which holds bindings of special
    Gerd> variables?

Actually it seems to be both (and an alien stack).  There's the
control-stack-fork vop and friends that copy the control stack.
multi-proc has stuff about the binding stack and alien stack.

    >> The obvious solution is adjusting the stack pointer to point to the
    >> new control stack, with no copying.  Do not know if this would work
    >> or not.

    Gerd> Well, I guess one would have to frob SYMBOL-VALUE to make this work.
    Gerd> One could store symbol values for each thread in thread-local storage,
    Gerd> and let SYMBOL-VALUE retrieve it from there.

That would make symbol-value much slower wouldn't it?

    Gerd> On x86, I think its common to use one of the segment registers FS or
    Gerd> GS to implement per-thread data.  A thread switch changes the value of
    Gerd> the segment register, and instructions with a segment prefix can be
    Gerd> used to access thread-local data.

    Gerd> I hope that's approximately right; it must have been >10 years since I
    Gerd> last used that :).

I think that's  how SBCL implements it's threads on Linux. :-)

Ray

Reply via email to