emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multi-threaded Emacs


From: Stefan Monnier
Subject: Re: multi-threaded Emacs
Date: Sat, 06 Dec 2008 17:41:20 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>     It will be safe in the sense that it won't cause a crash.  But it will
>     mess up Elisp's semantics.  Consider:

>        (dotimes (i 1000) (toto))

>     if you run this code twice in separate threads and allow context
>     switches at QUIT, then you'll basically be doing "preemptive
>     concurrency" seen from Elisp's point of view.  Among other things, the
>     two threads will be fighting over the value of `i'.

> Each thread should have its own local bindings.  To do this
> requires swapping bindings in and out of the specpdls
> when switching threads.  It is not hard.

> This makes thread switches slower, and that makes it desirable
> to do them less often.

It might be an acceptable temporary solution, but in the long term we
will want to allow true parallelism, so such trickery will not be
an option.

Whether it'll be a valuable intermediate point or not, I cannot say.
My gut feeling is that we'd better work on a solution that will work in
the longer run.  Currently my guess is that generalizing the existing
buffer-local/frame-local/terminal-local machinery to include
thread-local is going to work well, with fairly limited changes.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]