emacs-devel
[Top][All Lists]
Advanced

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

Re: multi-threaded Emacs


From: Richard M Stallman
Subject: Re: multi-threaded Emacs
Date: Sun, 30 Nov 2008 11:43:21 -0500

The main issue about multiple threads in Emacs is,
when should a thread-switch be possible?  I think it should
be allowed only where quitting is allowed.  Otherwise,
internal data can be made inconsistent.

Does pthreads provide the option to forbid thread-switching except
when the code calls a specific function?  If so, we could make the
QUIT macro run that function if there is more than one thread.

    (create-thread) 
    (with-thread id '(code))
    (kill-thread id)

It seems to me that `with-thread' should be renamed to
`run-in-thread'.  Meanwhile, `with-thread' should be a macro that
creates a new thread, starts running the body code in it, and will
kill it when that body code finishes.

It is un-Lispy to represent threads with numbers.  They should be
represented by objects that contain info about them.  If there is a
table of threads, it should not have a fixed size -- it should be
extended with realloc whenever it gets full.

What should happen when another thread gets an error?  Should Emacs
run the debugger in that thread?  (Probably rather annoying.)  Kill
the thread?  Leave the thread somehow suspended to be examined (but
how?).  Kill the thread, and leave some info about the error in the
dead thread object?  Perhaps there should be a way to specify a choice
for each thread.

    I haven't well investigated all problems that will raise using threads
    in Emacs, the first one that come to my attention is the garbage
    collector and at the moment I simply disable GC while there are running
    threads.

It should not be hard to find all the existing threads and mark all
their stacks and specpdls.






reply via email to

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