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: Fri, 05 Dec 2008 10:36:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>     Actually, yielding in QUIT will take a lot of work.  It's definitely not
>     "cooperative" seen from Elisp's point of view (where QUIT can be run
>     implicitly all over the place).

> I am surprised.  Perhaps you're right, but why do you think so?
> Anywhere that calls QUIT is a place where it is safe for an error to happen,
> so why not a thread switch?

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'.

So before this level of concurrency can be made to work we'll need to
fix dynamic scoping to be "per-thread" rather than global.

Note that the `yield' primitive won't be easy to use for the same kind
of reason (until we fix dynamic-scoping that is).


        Stefan




reply via email to

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